Forum Discussion

ashwinkolte's avatar
ashwinkolte
Icon for Helper III rankHelper III
3 years ago

Need help with Month over month calculation

I have input dataset like this :

 

 

ItemSub ItemMonthCost
Item 1Subitem 130-Jun-23200
Item 1Subitem 230-Jun-23300
Item 1Subitem 131-May-23400
Item 1Subitem 231-May-23600
Item 2Subitem 131-May-23500

 

 

I want to caculate Month over month cost saving  i.e June month cost - May month cost for the various items and subitems .

Require a matrix outout like this -

 

ItemSub Item30-Jun-2331-May-23Cost Saving
Item 1Subitem 1                 200400-200
Item 1Subitem 2                 300600-300
Item 2Subitem 1                    -  500-500
 Total row                 5001500-1000

I

The challenge I am facing is this .. If you see the Item 2 in the input data ,  It does NOT have any record (i.e cost)  for June month . There is May cost which is 500 . In this case I want June cost to be considered zero and cost saving calculated as (0-500) = -500 and the above matrix to be created with proper totals 

 

In other words it is as good as inserting below row in input data 

 

Item 2Subitem 130-Jun-230

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ashwinkolte ,

    Please reference the table in powerquery.

    Select the month column and pivot.

    add a custom column.

    create a new table visual.

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

    • ashwinkolte's avatar
      ashwinkolte
      Icon for Helper III rankHelper III

      Hi Anonymous 

       

      The table in question is a calculated table . Hence cannot edit in power query . Also please note that the real life data would contain many months and not just june and may