Forum Discussion
Apply filter based on value in other table and compute average
- 2 years ago
Try the below measure.
Avg_New = CALCULATE(AVERAGE('Table'[Avg]),ALL('Table'[Store]))Best regards,
Ismail | MiTutorials
Explore over 200+ Power BI tutorials and enhance your skills!
Try the below measure.
Avg_New = CALCULATE(AVERAGE('Table'[Avg]),ALL('Table'[Store]))
Best regards,
Ismail | MiTutorials
Explore over 200+ Power BI tutorials and enhance your skills!
Hi Ismail,
Won't this just the take average amount over all regions?
- miTutorials2 years ago
Super User
If you have the region field on the table, it will not. Do give it a try and let me know if this does not work! We can then tweak the code.
- sman2 years agoFrequent Visitor
It doesn't work, instead of the expected value of 17.5, I get 15.
I can obtain the result I want through thisAverage new = VAR selectedRegion = selectedvalue(Stores[Region]) RETURN CALCULATE( Average(Sales[Amt]), ALL(Stores), Stores[Region] == selectedRegion )But doing this I clear all my other filters. For example, let's say I have another column on sales which is "ARTICLE_CATEGORY" (e.g. shoes, pants etc). If a user has selected pants, I don't want to drop this filter. According to the documentation (ALL function (DAX) - DAX | Microsoft Learn) I'm supposed to be able to pass the columns which I want to drop but I'm not sure how to apply it here...
Edit: It wasn't that hard! Got it to work by specifying another calculate call with a filter on selected product categories! Thank you!- miTutorials2 years ago
Super User
Within ALL you should just pass in the column Name (Store in your example) and not the entire table.