The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.