Forum Discussion
Help with KEEPFILTERS within Calculation(Average)
- Anonymous9 years ago
I'm 97% sure you are making this more complicated than necessary. In as much as that I have been writing DAX for closer to 4 years and have no idea what KEEPFILTERS() even does :-P
Not to ask a crazy question, but what is wrong w/ :
AvgMeasureWeek = CALCULATE(AVERAGE('Table'[MaxPerDay]),FILTER(ALL('Date'),'Date'[WeekNum]=MAX('Date'[WeekNum])))
?
Thanks!
How would that be represented, so that, I don't remove the currently selected report filters, but ensure that WeekNum is an additivie filter in the formula only? I must be missing something simple?
AvgMeasureWeek = CALCULATE(AVERAGE('Table'[MaxPerDay]),FILTER(ALL('Table'),'Table'[WeekNum]=MAX('Date'[WeekNum])))
With the suggestions and additonal review of documentation - wow....
Looks like this is an appropriate solution:
AvgMeasureWeek3 = CALCULATE(AVERAGE('Table'[MaxPerDay]),KEEPFILTERS(VALUES('Table'[MaxPerDay])),FILTER('Table','Table'[WeekNum]=MAX('Date'[WeekNum])))
As I am gettinig correct results.
Can anyone comfirm?
Thanks,
- Anonymous9 years agoNot applicable
I'm 97% sure you are making this more complicated than necessary. In as much as that I have been writing DAX for closer to 4 years and have no idea what KEEPFILTERS() even does :-P
Not to ask a crazy question, but what is wrong w/ :
AvgMeasureWeek = CALCULATE(AVERAGE('Table'[MaxPerDay]),FILTER(ALL('Date'),'Date'[WeekNum]=MAX('Date'[WeekNum])))
?
- drosencrans9 years agoFrequent Visitor
Hey Scott-
You are right! Replacing Table with Date fixed the complexity I was working around.
Thanks for the direction! Helps a lot.
Doug