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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Previous Month of Selected Month not Working

Hi, I am calculating some values with the following DAX Formula:

Trial_Actual =
VAR SelectedMonth =
IF(
HASONEVALUE('Calendar'[Month Number]),
SELECTEDVALUE('Calendar'[Month Number]),
[Latest Month]
)
VAR var_volume = CALCULATE(SUMX(VW_WATERFALL, VW_WATERFALL[DATA]), VW_WATERFALL[CATEGORY] = "VOLUME")
RETURN
SUMX(
FILTER(
VW_WATERFALL,
VW_WATERFALL[MES] = SelectedMonth
),
VW_WATERFALL[DATA]/var_volume
)

 And it successfuly returns the correct values for the selected month:

aldobc2_0-1721057423785.png

But I also need to calculate the values for the previous month and this is what mi current DAX looks like but for some reason it ain't working.

trial_previous =
VAR P_Month = PREVIOUSMONTH('Calendar'[Date])
VAR var_vol = CALCULATE(SUMX(VW_WATERFALL, VW_WATERFALL[DATA]), VW_WATERFALL[CATEGORY] = "VOLUME")
RETURN
CALCULATE(
SUMX(VW_WATERFALL,
VW_WATERFALL[DATA])/var_vol,
PREVIOUSMONTH('Calendar'[Date])
)

This DAX is returning the values from the previous month BUT are being divided by the volume of current month. That's the problem I haven't figured out a way to fix. I've tried other alternatives of fx PREVIOUSMONTH() like "selected month - 1", but for some reason none have worked out. And in my var_vol variable, if I modify the filter in CALCULATE to "VW_WATERFALL[CATEGORY] = "VOLUME" && P_Month" I get an error that says "A table of multiple values was suppleid where a single value was expected".

 

So in a nutshell, for my previous-month values DAX formula, I need for my var_vol variable to be the volume from previous month.

 

Thank you.

1 ACCEPTED SOLUTION
GuillaumePower
Resolver I
Resolver I

Hello, if you have to use a stable filter and another  filter on changing  on the month, I think  you should use something  like that,  whith the intelligence function DateAdd :  ,DATEADD(DateTableWithCustomFiscalYear[Date],-1,Month))

You are shifting the month a month before, (you can use too whith Year,Quarter...)

 

GuillaumePower_0-1721062536330.png

 

View solution in original post

2 REPLIES 2
GuillaumePower
Resolver I
Resolver I

Hello, if you have to use a stable filter and another  filter on changing  on the month, I think  you should use something  like that,  whith the intelligence function DateAdd :  ,DATEADD(DateTableWithCustomFiscalYear[Date],-1,Month))

You are shifting the month a month before, (you can use too whith Year,Quarter...)

 

GuillaumePower_0-1721062536330.png

 

Anonymous
Not applicable

Thank you so much Guillaume! Using DATEADD definitely simplified the approach. Just as I had to create one measure to sum values for "Actual" and one for "Previous", I also created 2 measures to sum the value of "Volume", one for actual and another ofr previous and divided each correspondant measure.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.