Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Summarize all values for subtotal in Matrix

I have a matrix I am using to calculate the most up-to-date sales numbers from my database. Each day the new total is updated to the database, so I wrote a measure to grab the most up-to-date sales number for each customer. The problem comes when I want to show the total of each division (in this case, division "I" should have 1841 as its subtotal, not the minimum value (in this case, 478).

 

How do I specify to sum the distinct values for each division? I would even be happy with turning off subtotals, and adding an additional column with to show that data. Preferably we could adjust how power BI calculates subtotals.

 

Let me know if there is a way to do this! Thanks for your Time!

 

Marco C.

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi  Anonymous ,

     

    Here are the steps you can follow:

    1. Create measure.

    Measure =
    IF(
         NOT(ISINSCOPE('Table'[Division])),SUMX(ALL('Table'),[GranSalesToday]),
         IF(
            ISINSCOPE('Table'[Group]),         SUMX(FILTER(ALL('Table'),'Table'[Division]=MAX('Table'[Division])&&'Table'[Group]=MAX('Table'[Group])),[GranSalesToday])        
             ,
    IF(
        NOT(ISINSCOPE('Table'[Group])),
        SUMX(FILTER(ALL('Table'),'Table'[Division]=MAX('Table'[Division])),[GranSalesToday])
        ,0)
    ))

    2. Result:

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

4 Replies