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!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi All,
I require help in getting AVG of the last 5 nonblank values from column B. My table is setup like this:
So, pickup values 3788, 3522, 3604, 2326, 3058 and then avg it.
Can someone help?
Thanks.
Solved! Go to Solution.
I would suggest this measure - a slight modification of the above reply that ensures the top 5 dates are taken from those where B is not blank:
Average of B Over Last 5 Nonblank Dates =
VAR Last5Dates =
CALCULATETABLE (
TOPN ( 5, VALUES ( YourTable[Date] ), YourTable[Date] ),
NOT ISBLANK ( YourTable[B] )
)
RETURN
CALCULATE ( AVERAGE ( YourTable[B] ), Last5Dates )
Regards,
Owen
I would suggest this measure - a slight modification of the above reply that ensures the top 5 dates are taken from those where B is not blank:
Average of B Over Last 5 Nonblank Dates =
VAR Last5Dates =
CALCULATETABLE (
TOPN ( 5, VALUES ( YourTable[Date] ), YourTable[Date] ),
NOT ISBLANK ( YourTable[B] )
)
RETURN
CALCULATE ( AVERAGE ( YourTable[B] ), Last5Dates )
Regards,
Owen
Hey Ranbeer,
Hello!
The CALCULATE expression allows you to compute values based on certain filters, more info here.
So you would say
CALCULATE(AVERAGE(Column Name),Column Name<>BLANK())
And then in order to select the last 5 measures, you can select the column name in the filters selection > Select ‘Top N’ in the drop-down > switch it to Bottom > enter 5.
Or if you have ranked the column by date, and on the filter, select whichever ones you want by adding another filter to the CALCULATE measure:
CALCULATE(AVERAGE(‘Column Name’),’Column Name’<>BLANK(),’Date’ > (Specific Date))
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!