Forum Discussion
tavolo89
3 years agoFrequent Visitor
SWITCH statement based on a measure is not working
I've created the following three measures to try and assign a percentile to products based on the number of views. ItemRank_Views = IF ( NOT ( ISBLANK ( [# Product Views] ) ), RANKX ( ...
edhans
Community Champion
3 years agoWhen you use a measure inside of a column, you are only going to get the results of that measure for that one row. That is part of what Context Transition is doing. You need to wrap that measure with CALCULATE() and add some REMOVEFILTERS() logic to negate the effects of the context transition. You'll need to play with the REMOVEFILTERS though to find out what has to be cleared. I would ignore the SWITCH for now, and just drop those measures directly in the column and look at the results. Then wrap it with CALCULATE([your measure], REMOVEFILTERS(sometable), REMOVEFITLERS(someothertable[somecolumn0)) until it returns what you want. Then reassemble your SWITCH function.