Forum Discussion
Using SWITCH with variables and filters in measures
- 5 years ago
You can't return a table in a SWITCH (or an IF), which is the problem with your measure. You'll need to switch between full expressions (like Amit suggested). You could explore using CROSSJOIN to precombine your filters or using Calculation Groups, but I don't know if that would work.
Pat
Hi amitchandak !
Thanks for trying to solve this.
This is correct but does not solve my problem, because what I wanted to do is to isolate the filters in variables so that I could cross multiple filters in my calculate at the end. Eventually, it would look kind of like this:
Var Filter1 = ...
Var Filter2 = ...
Var Filter3 = ...
Var SelectedFilter1 = SWITCH.. (selects one of the filters above)
Var SelectedFilter2 = SWITCH.. (selects one of the filters above)
Return CALCULATE([TotalSales], SelectedFilter1, SelectedFilter2)And my problem here is with this SWITCH function that apparently does not return what my CALCULATE function would like as filters. Any ideas for that? Thanks!
You can't return a table in a SWITCH (or an IF), which is the problem with your measure. You'll need to switch between full expressions (like Amit suggested). You could explore using CROSSJOIN to precombine your filters or using Calculation Groups, but I don't know if that would work.
Pat
- SamuelDesguin5 years agoRegular Visitor
Aaah right mahoneypat , that makes sense. I'll try another way, then ! Thanks a lot.