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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
arun2001mjl
Helper II
Helper II

Need help on Month to Month Cost Gap in %

Hello Team,

 

I need your help to find Previousmonth (Jan23) & CurrentMonth(Feb 23) Delta and also Currentmonth (Feb 23) and April 2022 (Baseline) Delta. Iam using the below DAX but it is calculating all Cost.

 

Current Month

MAX Year CostActual = CALCULATE(SUM('ABC'[Cost]), 'Dim Period'[Year] = MAX('Dim Period'[Year]))
-MAX Year CostActual = CALCULATE(SUM('ABC[Cost]), DATEADD('Dim Period'[Year],-1,MONTH))
 
MAX Year CostActual shows Feb Month Cost but -MAX Year CostActual taken Total Cost and subtracting the Feb month cost which is not correct.
 
Below is the Table and Calculations.
 Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22Jan-23Feb-23delta vs last monthdelta vs baseline
Trend 6506366205007005506506666366506662.46%2.40%
Technology1244536366205007005506506666368955255471-38.06%55.92%
Technology2666666620500700550650666636650590-9.23%-12.88%
Technology37007006205007005506506666366506662.46%-5.11%
Technology45905906205007005506506666366506601.54%10.61%
Technology56666666205007005506506666366506662.46%0.00%
Technology66506366205007005506506666366667005.11%7.14%
Technology7666636620500700550650666636700590-15.71%-12.88%
Technology870063662050070055065066663659066612.88%-5.11%
Technology95906366205007005506506666366666660.00%11.41%
Technology10666636620500700550650666636700666-4.86%0.00%
Technology1165063662050070055065066663659066612.88%2.40%
Technology126506366205007005506506666366666660.00%2.40%
Technology136506366205007005506506666366506662.46%2.40%
 
1) Delta Vs Last month is calcuated based on (Feb-23 - Jan-23)/Jan-23 (Should be dynamic for everymonth)
2) Delta Vs Baseline is Calculated baesd on (Feb-23 - Apr-22)/Feb-23 (april is baseline here - Static)
 
Could you please help with this calculation in PowerBI.
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

- you show too much data (only Apr 22, Jan 23 and Feb 23 are required)

- the data is not in a usable format - please unpivot the month columns

- you  don't seem to be using a proper calendar table. Time intelligence functions like DATEADD require a contiguous and covering date column.

- don't use MAX inside of CALCULATE  unless you intend to modify the filter context like that. Better use variables.

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

- you show too much data (only Apr 22, Jan 23 and Feb 23 are required)

- the data is not in a usable format - please unpivot the month columns

- you  don't seem to be using a proper calendar table. Time intelligence functions like DATEADD require a contiguous and covering date column.

- don't use MAX inside of CALCULATE  unless you intend to modify the filter context like that. Better use variables.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors