Forum Discussion
Correct subtotal percentages
Hi there,
I have the following matrix with subtotals, totals and percentages:
I made the following DAX formulas to calculate OU%:
OU% = OverigeUren% = Calculate(CONCATENATE(FIXED(DIVIDE([OverigeUren];[GrandTotal];0)*100;2;0);"%")) OU = OverigeUren = CALCULATE(SUM(EMPLOYEE[LABOR_TICKET.1.HOURS_WORKED]); FILTER(EMPLOYEE;EMPLOYEE[LABOR_TICKET.1.INDIRECT_ID]<>"")) GT = GrandTotal = [OverigeUren]+[ProjectUren]
As can be seen the total of OU%, which is 46,90%, is correct. However, the subtotals of OU% are alle 100%. How can I modify the DAX such that the subtotal percentages sum up to to 46,90% on the basis of the corresponding subtotals in the OU column?
So I want the subtotals of the OU column and OU% column to show:
OU: OU%:
6.00 1,12
23,02 4,29
...... ......
251,52 46,90%
So the calculation then become 6/536,27=0,0112 * 100 = 1,12 etc.
UPDATE
Ok I now managed to do the following, which yields the desired result:
OverigeUren% = CALCULATE(DIVIDE(CALCULATE(sum(EMPLOYEE[LABOR_TICKET.1.HOURS_WORKED]);FILTER(EMPLOYEE;EMPLOYEE[LABOR_TICKET.1.INDIRECT_ID]<>""));536,27)*100)
However, if I replace the 536,27 by sum(EMPLOYEE[LABOR_TICKET.1.HOURS_WORKED]), I get the same result again as in the image above.....
Hi v-huizhn-msft. Never mind. Got a solution :smileyvery-happy:. The solution I am using is as follows:
OverigeUren% = CALCULATE(DIVIDE(CALCULATE(sum(EMPLOYEE[LABOR_TICKET.1.HOURS_WORKED]);FILTER(EMPLOYEE;EMPLOYEE[LABOR_TICKET.1.INDIRECT_ID]<>""));CALCULATE(SUMX(VALUES(EMPLOYEE[LABOR_TICKET.1.INDIRECT_ID]);EMPLOYEE[LABOR_TICKET.1.HOURS_WORKED]);ALLSELECTED(EMPLOYEE)))*100)
Thank you very much for your support.
3 Replies
- v-huizhn-msft
Microsoft Employee
Hi Cootje16,
Please create use the formula below and check if it works fine.OverigeUren% = VAR SS = SUM ( EMPLOYEE[LABOR_TICKET.1.HOURS_WORKED] ) RETURN CALCULATE ( DIVIDE ( CALCULATE ( SUM ( EMPLOYEE[LABOR_TICKET.1.HOURS_WORKED] ), FILTER ( EMPLOYEE, EMPLOYEE[LABOR_TICKET.1.INDIRECT_ID] <> "" ) ), SS ) * 100 )
If you still have issue, you'd better share your .pbix file for further analysis.
Best Regards,
Angelia- Cootje16Frequent Visitor
Thanks v-huizhn-msft for your solution. However, your solution still yields the same result as the results in the picture I posted in my first post. You can download my PBIX file on the following link:
https://drive.google.com/file/d/1BBbFm1g9mt8vRHGTvBSlTbggST6JFd_d/view?usp=sharing
- Cootje16Frequent Visitor
Hi v-huizhn-msft. Never mind. Got a solution :smileyvery-happy:. The solution I am using is as follows:
OverigeUren% = CALCULATE(DIVIDE(CALCULATE(sum(EMPLOYEE[LABOR_TICKET.1.HOURS_WORKED]);FILTER(EMPLOYEE;EMPLOYEE[LABOR_TICKET.1.INDIRECT_ID]<>""));CALCULATE(SUMX(VALUES(EMPLOYEE[LABOR_TICKET.1.INDIRECT_ID]);EMPLOYEE[LABOR_TICKET.1.HOURS_WORKED]);ALLSELECTED(EMPLOYEE)))*100)
Thank you very much for your support.