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.
I tried to create a measure of last 6 month weighted average days, the measure is as follows;
But when I manually checked for individual accounts for the last 6 months and it does not match all.
Is there a problem with the measure and what needs to be corrected if so.
Try this one:
// Last 6-Month Weighted Average
[Last 6M Wt Avg] =
var __lastDate = MAX( 'Date'[Calendar Date] )
var __veryFirstDateInCalendar =
FIRSTDATE(
ALL( 'Date'[Calendar Date] )
)
// we have to check if there are enough days
// in the Date table to cover the 6Mth period
// starting from __lastDate (and going back).
// If not, we have to return BLANK().
var __boundaryDate =
DATEADD(
__veryFirstDateInCalendar,
+6,
MONTH
) - 1
var __result =
if( __boundaryDate <= __lastDate,
var __period =
DATESINPERIOD(
'Date'[Calendar Date],
__lastDate,
-6,
MONTH
)
var __avg =
CALCULATE(
[Wt avg 2],
__period
)
return
__avg
)
return
__result
Of course, the Date table must be marked as such in the model and the unique date indentifier must be the 'Date'[Calendar Date] column. Since this table should contain at least 1 full year of dates, the code above works correctly.
Thankyou @Anonymous , I madea small change, instead of using the calender date I used the payment recieved date and individually records are correct but when it shows as total its not the correct value. Below is the measure:
Though the measure works it still gives inaccurate total.
@Avivek , try like
Last 6 months Wt Avg =
VAR enddate = EOMONTH('LAST REFRESHED'[Data Last Refreshed],-1)
VAR startdate = EOMONTH(enddate,-6)+1
VAR wtavg =
CALCULATE( [Wt avg 2],
FILTER('DATE','DATE'[Calendar Date]>= startdate && 'DATE'[Calendar Date]<= enddate)
)
@amitchandak , it shows an error
It may seem a little silly, please don't mind as I am still at a beginner level and maybe I am missing some logic behind the syntax
@Avivek , try like
Last 6 months Wt Avg =
VAR enddate = EOMONTH('LAST REFRESHED'[Data Last Refreshed],-1)
VAR startdate = EOMONTH(enddate,-6)+1
return
CALCULATE( [Wt avg 2],
FILTER('DATE','DATE'[Calendar Date]>= startdate && 'DATE'[Calendar Date]<= enddate)
)
Hi @amitchandak
I made soome changes in the measure and changed it to payment received date instead of calendar date and although it gives the right individual value but the total is not correct
Though the measure works it still gives inaccurate total.
@amitchandak It gives same answer, the new measure I named it as Last 6 month Wt Avg3,
also in this pic if we see in month and year it should be only for 6 months buts its showing for all the months and year, ideally by the measure it should be for 07/2020, 06/2020, 05/2020, 04/2020, 03/2020, 02/2020.
So I am not able to figure it out what is it i am missing, can you please help me out here.
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.