Forum Discussion

Miska's avatar
Miska
Icon for Helper I rankHelper I
5 years ago
Solved

Need to append running difference between two categories in a row in a report table

Hi!

 

I have a report table where there is a first column with different categories and followed by Current Month amount, previous month amt, YTD amounts . I need to append a new row in the report which will show me the difference between two categories when the report is refreshed.

CategoryCY AmtPY AmtYTD Amt
Sales42435664356
Cost534564747575
Salary53456644577567
Expenses54345668678
Oveheads646446458678

1

 

I want to create a new row within the same table which will show me a new category with a difference between the Sales and the cost as Gross Profit

 

Something like this:

 

CategoryCY AmtPY AmtYTD Amt
Sales42435664356
Cost534564747575
Gross Profit-1102-810-7219
Salary53456644577567
Expenses54345668678
Oveheads646446458678

 

Any help will be greatly appreciated

 

Thanks

  • Hi Miska ,

     

    In PowerBI, the newly added data exists in the form of rows, and different dax are created to calculate different columns. I did the following test. I need to transpose the rows and columns in the power query first, and then create a measure in the desktop to calculate the Gross Profit for the sales column and the cost column.

     

    Gross-Profit = MAX('Table (2)'[Sales])-MAX('Table (2)'[Cost])


    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.

    Best Regards,
    Henry

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

3 Replies

  • v-henryk-mstf's avatar
    v-henryk-mstf
    Icon for Community Support rankCommunity Support

    Hi Miska ,

     

    In PowerBI, the newly added data exists in the form of rows, and different dax are created to calculate different columns. I did the following test. I need to transpose the rows and columns in the power query first, and then create a measure in the desktop to calculate the Gross Profit for the sales column and the cost column.

     

    Gross-Profit = MAX('Table (2)'[Sales])-MAX('Table (2)'[Cost])


    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.

    Best Regards,
    Henry

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

    • Miska's avatar
      Miska
      Icon for Helper I rankHelper I

      We have like Category and subcategories under the categories so it will be like around 100 subcategories and couple million records for this. I tried it but does not seem to work .

       

      Thanks

      • v-henryk-mstf's avatar
        v-henryk-mstf
        Icon for Community Support rankCommunity Support

        Hi Miska ,

         

        What is the specific error display, transpose the rows and columns in the power query should not affect the calculation. Can you provide detailed test data model information (delete sensitive information), I will answer you as soon as possible.


        Looking forward to your reply.

        Best Regards,
        Henry