Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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))
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |