Thank you guys.
Great code and examples!
I little will update the topic.
First
In TM1 Drill Process in the Prolog Tab write (Thx
rmackenzie):
Code: Select all
vUserLogin = TM1User () ;
vUserName = ATTRS ( '}Clients' , vUserLogin , '}TM1_DefaultDisplayValue' ) ;
##### Company
# variable for generated SQL
sSQL='';
# we need the children of this consolidated element in Company dimension
sDimName = 'Company';
sParentElemName=Company;
# build subset in Company dimension with all leaf children of the parent
sSubName='zTemp_TM1_DRILL_DOWN_PL_V_' | vUserName ;
SubsetCreateByMdx(sSubName,'{TM1FILTERBYLEVEL( {TM1DRILLDOWNMEMBER( {['|sDimName|'].['|sParentElemName|']}, ALL, RECURSIVE )}, 0)}');
# iterate subset and add leaf elements to SQL statement
nCounter=1;
nMaxCount= SubsetGetSize(sDimName,sSubName);
WHILE(nCounter<=nMaxCount);
sElemName= SubsetGetElementName(sDimName,sSubName,nCounter);
# make sure it is principal name to match values in source system
# probably don't need this line - the MDX should return this
sPrincipalElemName= DimensionElementPrincipalName(sDimName,sElemName);
# update SQL
sSQL=sSQL|CHAR(39)|sPrincipalElemName|CHAR(39);
# need a comma unless last item in subset
IF(nCounter<nMaxCount);
sSQL=sSQL|',';
ENDIF;
nCounter=nCounter+1;
END;
# clean up temp subset
SubsetDestroy(sDimName,sSubName);
# debug output
# AsciiOutput(LogProcess | 'searchCompany_' | vUserName | '.txt',sSQL);
# assign to drill-through query
searchCompany=sSQL;
Next the same code for all other Dimensions...
Second
Write query like this with Totals and Details or only with Details..:
(The Amount is MONEY type in SQL, and for my country a good representation of the sum is 1234567890,1234, so i "convert" is
REPLACE(CAST(SUM([Amount]) AS VARCHAR),'.',',') )
Code: Select all
/*Totals*/
SELECT
'' AS Version, '' AS Company, '' AS YearsMonths, '' AS CFR, '' AS AccountsPL, GetDate() AS AccountsDate, '' AS Projects, '' AS Contractors, '' AS [Other fields from accounting system],
REPLACE(CAST(SUM([Amount]) AS VARCHAR),'.',',') AS [Amount],
'?Company?' AS Company_Filter,
'?YearsMonths?' AS YearsMonths_Filter,
'?CFR?' AS CFR_Filter,
'?AccountsPL?' AS AccountsPL_Filter,
'?Projects?' AS Projects_Filter,
'?Contractors?' AS Contractors_Filter,
'?vUserName?' AS ReportUser
FROM [VD].[dbo].[TM1_DRILL_DOWN_PL_V]
WHERE
[Company] IN (?searchCompany?)
AND [YearsMonths] IN (?searchYearsMonths?)
AND [CFR] IN (?searchCFR?)
AND [AccountsPL] IN (?searchAccountsPL?)
AND [Projects] IN (?searchProjects?)
AND [Contractors] IN (?searchContractors?)
UNION
/*Details*/
SELECT
Version, Company, YearsMonths, CFR, AccountsPL, AccountsDate, Projects, Contractors, [Other fields from accounting system],
REPLACE(CAST([Amount] AS VARCHAR),'.',',') AS [Amount],
'?Company?' AS Company_Filter,
'?YearsMonths?' AS YearsMonths_Filter,
'?CFR?' AS CFR_Filter,
'?AccountsPL?' AS AccountsPL_Filter,
'?Projects?' AS Projects_Filter,
'?Contractors?' AS Contractors_Filter,
'?vUserName?' AS ReportUser
FROM [VD].[dbo].[TM1_DRILL_DOWN_PL_V]
WHERE
[Company] IN (?searchCompany?)
AND [YearsMonths] IN (?searchYearsMonths?)
AND [CFR] IN (?searchCFR?)
AND [AccountsPL] IN (?searchAccountsPL?)
AND [Projects] IN (?searchProjects?)
AND [Contractors] IN (?searchContractors?)
Third
To make the beauty for TM1WEB add to the end of the file
standaloner.css this (or similar) code:
( If you do not use Totals, then remove fourth line "...first-child + tr..." )
Code: Select all
table.relationalDrillThroughGrid tr:nth-child(even) {background-color: #eeeeff;}
table.relationalDrillThroughGrid tr:hover {background-color: #FFE669}
table.relationalDrillThroughGrid tr:first-child {background-color: #DFE3E8;color: #333333;font-weight:normal}
table.relationalDrillThroughGrid tr:first-child + tr{background-color: #DFE3E8;color: #333333;font-weight:bold}
table.relationalDrillThroughGrid td {height: 15px;vertical-align: top;padding: 5px;text-align:left;border-bottom: 1px solid #000;font-family: tahoma,arial,sans-serif;font-size:11px}
(after: stop the TM1 Applications service, delete the contents of the ..\tm1web\excelsheet directory, start TM1 Applications service, сlear the web browser cache)
Thx David Nyman. Link for details:
http://blogg.attollo.se/2016/02/pimpa-u ... drill.html
FIN