Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
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:
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.
Solved! Go to Solution.
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...)
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...)
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.
User | Count |
---|---|
10 | |
8 | |
5 | |
5 | |
4 |