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.
I was trying to generate a 5-week average volume. Does anyone know why the first formula work but not the second one?
Vol Avg5WK = calculate(Divide(SUM('2014Data'[#Shipments]),5),FILTER(all('2014Data'),'2014Data'[WeekNum]>=MAX('2014Data'[WeekNum])-5 && '2014Data'[WeekNum]<=MAX('2014Data'[WeekNum])-1))
Vol Avg5WK = calculate(Divide(SUM('2014Data'[#Shipments]),5),FILTER('2014Data','2014Data'[WeekNum]>=MAX('2014Data'[WeekNum])-5 && '2014Data'[WeekNum]<=MAX('2014Data'[WeekNum])-1))
The difference is I removed All() from Filter function.
Many thanks!
Solved! Go to Solution.
@Anonymous wrote:
I was trying to generate a 5-week average volume. Does anyone know why the first formula work but not the second one?
Vol Avg5WK = calculate(Divide(SUM('2014Data'[#Shipments]),5),FILTER(all('2014Data'),'2014Data'[WeekNum]>=MAX('2014Data'[WeekNum])-5 && '2014Data'[WeekNum]<=MAX('2014Data'[WeekNum])-1))
Vol Avg5WK = calculate(Divide(SUM('2014Data'[#Shipments]),5),FILTER('2014Data','2014Data'[WeekNum]>=MAX('2014Data'[WeekNum])-5 && '2014Data'[WeekNum]<=MAX('2014Data'[WeekNum])-1))
The difference is I removed All() from Filter function.
Many thanks!
@Anonymous
It is the Context that make those two measures show differently, see Understanding Evaluation Contexts in DAX. The ALL function returns all the rows in a table, or all the values in a column, ignoring any filters that might have been applied. ALL function is useful for clearing filters and creating calculations on all the rows in a table. For example, if the context refers to all rows, eg in a Card visual, Those two measure would give the same output.
@Anonymous wrote:
I was trying to generate a 5-week average volume. Does anyone know why the first formula work but not the second one?
Vol Avg5WK = calculate(Divide(SUM('2014Data'[#Shipments]),5),FILTER(all('2014Data'),'2014Data'[WeekNum]>=MAX('2014Data'[WeekNum])-5 && '2014Data'[WeekNum]<=MAX('2014Data'[WeekNum])-1))
Vol Avg5WK = calculate(Divide(SUM('2014Data'[#Shipments]),5),FILTER('2014Data','2014Data'[WeekNum]>=MAX('2014Data'[WeekNum])-5 && '2014Data'[WeekNum]<=MAX('2014Data'[WeekNum])-1))
The difference is I removed All() from Filter function.
Many thanks!
@Anonymous
It is the Context that make those two measures show differently, see Understanding Evaluation Contexts in DAX. The ALL function returns all the rows in a table, or all the values in a column, ignoring any filters that might have been applied. ALL function is useful for clearing filters and creating calculations on all the rows in a table. For example, if the context refers to all rows, eg in a Card visual, Those two measure would give the same output.
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 |
---|---|
14 | |
2 | |
2 | |
1 | |
1 |