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!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hello,
I am relatively new to Power BI. I use the following measure to calculate last 6 months average, excluding current month:
6MonthResolvedAVG =
CALCULATE(SUMX('Data Table',IF(DATEDIFF('Data Table'[Date],TODAY(),MONTH) >0,[ResolvedCR],0)),
DATESINPERIOD('Data Table'[Date],EOMONTH (lastdate('Data Table'[Date]) , -1 ),-6,MONTH))/6
It works correctly for recent data. However.... if I apply some filters and there is no current data but , let's say data is from 2019, then the measure still calculates something, which is incorrect. I need to force the measure to use maximum date from the table as of today and not a "relative" date depending on the filters.
Expected behavior: if there isn't any data for the past 6 months,excluding current month and calculated from absolute maximum date in the table, then display 0.
Please advise.
Regards,
M. R.
Solved! Go to Solution.
OK. It makes sense now. You've defined a calculated column 'Combined_CQ_view'[ResolvedCR] instead of a measure.
Therefore you need to adjust the formula. Like this, for example:
6MonthResolvedAVG =
VAR PrevMonth =
EOMONTH ( CALCULATE ( MAX ( 'Combined_CQ_view'[Date] ), ALL ( 'Combined_CQ_view' ) ), -1 )
RETURN
CALCULATE (
SUM ( 'Combined_CQ_view'[ResolvedCR] ),
DATESINPERIOD ( 'Combined_CQ_view'[Date], PrevMonth, -6, MONTH )
) / 6
I'd suggest calculating the end of the last month as a variable first and then using in your date filtering.
6MonthResolvedAVG =
VAR PrevMonth =
EOMONTH ( CALCULATE ( MAX ( 'Data Table'[Date] ), ALL ( 'Data Table' ) ), -1 )
RETURN
CALCULATE (
[ResolvedCR],
DATESINPERIOD ( 'Data Table'[Date], PrevMonth, -6, MONTH )
) / 6
Thank you Alexis but [ResolvedCR] is a measure, not a table column and I get "Cannot find name '[ResolvedCR]'".
Can you please advise how to resolve this issue?
That error doesn't make sense to me. If the measure exists, it should be referencing it just like it did in your version.
Did the measure name change perhaps?
Measure did not changed but after looking at some older posts, it seems that referencing a measure in another measure may not work:
You can absolutely reference measures within other measures. Can you show a screenshot of your original measure that doesn't have an error but references the same measure? I'm really curious what the difference is.
This is the measure:
That's not a correctly written measure. It appears to be a calculated column, which might explain why it worked in your SUMX but not when called as a measure.
This is the original calculation, no error:
OK. It makes sense now. You've defined a calculated column 'Combined_CQ_view'[ResolvedCR] instead of a measure.
Therefore you need to adjust the formula. Like this, for example:
6MonthResolvedAVG =
VAR PrevMonth =
EOMONTH ( CALCULATE ( MAX ( 'Combined_CQ_view'[Date] ), ALL ( 'Combined_CQ_view' ) ), -1 )
RETURN
CALCULATE (
SUM ( 'Combined_CQ_view'[ResolvedCR] ),
DATESINPERIOD ( 'Combined_CQ_view'[Date], PrevMonth, -6, MONTH )
) / 6
It works now, thank you very much for your help !
@Anonymous , Try like
6MonthResolvedAVG =
if( CALCULATE(distinctcount('Date'[Month Year]),
DATESINPERIOD('Data Table'[Date],EOMONTH (max('Data Table'[Date]) , -1 ),-6,MONTH) , filter('Data Table',not(isblank([ResolvedCR])) )) <=6,0, CALCULATE([ResolvedCR],
DATESINPERIOD('Data Table'[Date],EOMONTH (max('Data Table'[Date]) , -1 ),-6,MONTH))/6)
Thank you Amit, but what is 'Date'[Month Year]? I don't have this table. Should I create it?
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.