Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
ashwinkolte
Helper II
Helper II

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 2
v-cgao-msft
Community Support
Community Support

Hi @ashwinkolte ,

Please reference the table in powerquery.

vcgaomsft_0-1693374299498.png

Select the month column and pivot.

vcgaomsft_1-1693374372486.png

vcgaomsft_2-1693374428153.png

add a custom column.

vcgaomsft_3-1693374467314.png

create a new table visual.

vcgaomsft_4-1693374540259.png

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

Hi @v-cgao-msft 

 

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

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!