Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
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.
User | Count |
---|---|
10 | |
5 | |
4 | |
4 | |
3 |
User | Count |
---|---|
14 | |
9 | |
5 | |
5 | |
4 |