Forum Discussion
Filter on calculated measure not working
I have the following measure, which is working as expected:
% Market Share = [Sales Amt]/Calculate([Sales Amt],ALL(Data[SellerName]))
I then want to calculate this measure, which is puzzlingly returning 100% (100% is definitely not correct):
% Online Market Share = Calculate([% Market Share],FILTER(Data,[ON/OFFLINE] = "Online")
Why is this filter not working?
The answer is using KEEPFILTERS, as explained in this article:
https://www.sqlbi.com/articles/order-of-evaluation-in-calculate-parameters/
4 Replies
- Jihwan_Kim
Super User
Hi,
Please try something like below whether it suits your requirement.
% Online Market Share = CALCULATE ( [Sales Amt], FILTER ( Data, [ON/OFFLINE] = "Online" ) ) / CALCULATE ( [Sales Amt], ALL ( Data[SellerName] ), FILTER ( Data, [ON/OFFLINE] = "Online" ) )- Tonio_EGRegular Visitor
Yes thanks, I did the same workaround.
But I would like to understand why the orginal approach (which is way cleaner) isn't working?
- Jihwan_Kim
Super User
Hi,
The parameter in the outer CALCULATE DAX function is replacing the parameter in the inner CALCULATE function.
In this case, instead of writing like this, in my opinion, writing two parameters in one CALCULATE DAX function is more clear to understand.
I hope this helps.
Thank you.
- Tonio_EGRegular Visitor
The answer is using KEEPFILTERS, as explained in this article:
https://www.sqlbi.com/articles/order-of-evaluation-in-calculate-parameters/