Forum Discussion

nirrobi's avatar
nirrobi
Icon for Helper V rankHelper V
10 years ago
Solved

Create measure % of total

Hi all,   I have table like the bellow. I need to add measure name "import % of Total" that calculate for each row import / total total (50/483, ... 230/483 etc.) How can you build this measure? ...
  • allaboutdata's avatar
    allaboutdata
    10 years ago

    Hey Nirrobi,

     

    can you try this?

     

    Import % of Total = var bigTotal = SUMX(ALL(Sheet1[Customer]), CALCULATE(SUM(Sheet1[Import]) + SUM(Sheet1[Export])))
                        return DIVIDE(SUM([Import]),bigTotal)

    Basically

     

    ALL(Sheet1[Customer])

    Forces it to do the calculation across all your customers. 

     

    CALCULATE(SUM(Sheet1[Import]) + SUM(Sheet1[Export])

    Says to do the sum of Import and Export on a row by row basis i.e. the total

     

    Wrapped with sumx it translates to, for all customers calculate the total on a row by row basis and then add together all the totals to get your Total of all totals.

     

    Your % of total then just becomes:

     

    DIVIDE(SUM([Import]),bigTotal)

    This is the output that i get:

     

    Capture.PNG