Forum Discussion

ghetus's avatar
ghetus
Frequent Visitor
9 years ago
Solved

Percent of group total

Hello,   I want create report in which will be sum of sales and percent from sum on group. I know in Power BI exists Quick measures, but they calculate percent from grand total, i need calculate pe...
  • tringuyenminh92's avatar
    9 years ago

    Hi ghetus,

     

    This is first time I'm facing with % total of multiple levels, so I separate it into 3 measures and use a trick with If condition to showing 3 measures for 3 levels.

     

    • Create % for the smallest level (items)

     

    % level 3 = DIVIDE(sum('Sales Data'[Sales]),CALCULATE(sum('Sales Data'[Sales]),ALLSELECTED('Sales Data'[Item])  ) )
    • The Second level

     

    % level 2 = DIVIDE(sum('Sales Data'[Sales]),CALCULATE(sum('Sales Data'[Sales]),ALLSELECTED('Sales Data'[Category])  ) )
    
    
    • And the first level (markets)
    % level 1 = DIVIDE(sum('Sales Data'[Sales]),CALCULATE(sum('Sales Data'[Sales]),ALLSELECTED('Sales Data'[Market])  ) )

     

    As my observation, when showng 1 level in matrix, the parent will be 100% or 1, so I will use IF condition to replace this value to its percentage in the previous level

    • Create measure for Level 2:

     

    Level 2 = if([% level 3]=1 , [% level 2],[% level 3])

     

    • Finally, create measure for level 1 with name % group:
    % group = if([Level 2]= 1,[% level 1] ,[Level 2])

     

     

    For more details, please kindly check my sample file and data for your case.

    It's late in Vietnam so i'm going to bed now, hope you take a look with some testing to ensure this is correct for all cases.

     

    If this works for you please accept it as solution and also like to give KUDOS.

    Best regards
    Tri Nguyen