Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Matrix Visual: Substract rows, but only first category

Hi all, 

 

my current task is to basically build a P&L in Power BI. 

We get our data from excel and is basically looks like this: 

In the real data we also have subsidairies, months, many other categories and stuff, but this should do. 

when putting this data in a power bi matrix I only recieve my data like this:

 

 

Power BI puts together the categorie levels and summs them up.

So far so good, but I need my data to look like this: 

 

Category Level 1 (Sales, pm1, pm2, pm3) should be substracted while catogory level 2 still shows the totals without being substracted. Does anyone know how this is possible?

 

I saw it working on another report, but I unfortunately don't have access to it. 

 

Thanks, Christian

 

 

 

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous 

    You can refer to the following measure

    Measure = IF(OR(MAX('Table'[Category Level 1])="Sales",ISINSCOPE('Table'[Category Level 2])),SUM('Table'[Ammount]),SUMX(FILTER(ALLSELECTED('Table'),[Category Level 1]="Sales"),[Ammount])+SUMX(FILTER(ALLSELECTED('Table'),[Category Level 1]<=MAX('Table'[Category Level 1])&&[Category Level 1]<>"Sales"),[Ammount]))

    Put the measure to the values in matrix visual

    Best Regards!

    Yolo Zhu

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

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

    You can refer to the following measure

    Measure = IF(OR(MAX('Table'[Category Level 1])="Sales",ISINSCOPE('Table'[Category Level 2])),SUM('Table'[Ammount]),SUMX(FILTER(ALLSELECTED('Table'),[Category Level 1]="Sales"),[Ammount])+SUMX(FILTER(ALLSELECTED('Table'),[Category Level 1]<=MAX('Table'[Category Level 1])&&[Category Level 1]<>"Sales"),[Ammount]))

    Put the measure to the values in matrix visual

    Best Regards!

    Yolo Zhu

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

     

  • Anonymous , In matrix visual, assume you are using measure  M1

    Try a measure like 

     

    If(isinscope(Table[Category Level 1]) && Not(Isinscope[Category Level 1]) && Not(Isinscope[Account Number]) && Table[Category Level 1] ="Sales"

    , calculate([M1], Table[Category Level 1] ="Sales") - calculate([M1], Table[Category Level 1] ="M1")

    ,[M1])

     

     

    Or consider the approach used in

     

    Power BI How to get the P&L formatting right: https://youtu.be/C9K8uVfthUU