Forum Discussion
Switch not working (only passing alternate value)
Scenario:-
• User selecteable Reporting level on slicer (running from static reference table)
• measure for the hierarchy Level works OK
RLSLevel = SELCTEDVALUE(RefEntryLevel[EntryLevel],3)
This displayes on a card OK
Test Column in structure table works OK when displayed on a table visualisation
• Dynamic structure DOES NOT change as expected
- using SWITCH(RLSLevel,1,[ColA],2,[ColB],2,[ColC])
* in the same table where I'm testing the RLSLevel output - another column will not update - ONLY bringing in the value of the alternate (which can be seen if I change the alternate in the switch between 1,2 or 3) thus ignoring the first part of the switch calculation
* Attempting to use an IF statement instead of switch also doesn't immediately update the table column
- IF(RLSLevel=1,[ColA],IF(RLSLevel=2,[ColB],[ColC]))
to me - it appears that no matter the result of the SELECTEDVALUE in the first part of the statement (as I see it working in the table result) - when the combining the result directly in a calculated column - it fails to bring in the expected value - ONLY carrying through the alternate - so, at best it delivers inconsistent results back to data and at worst it's completely unusable.
I see from other posts this has been a bit of an issue in various forms for some time (back to 2017) .. any update on a resolution for this?
4 Replies
- MFelix
Super User
Hi David_Ramos ,
Not sure if I understood correctly what you are trying to achieve, can you confirm to me that you are creating a new column on your model?
If that is the case the use of measures does not work on columns in the dataset because of the context, columns have row context and measure don't have it.
Can you share some sample data please?
- David_RamosFrequent Visitor
yes - I'm creating a new column (well .. sets of new columns) .. I know there are much better ways of dealing with hierarchies - but for this model I'm stuck with some ridiculous requirements of the business both at data provision and expected output). There are 3 sets 5 of columns coming in, and dependant on the 'selected view' I need to shift which set is used for filters and data in a static table for output.
in theory - what I want to achieve should be simple:-
Coumn 1 Column 2 Column 3 Dynamic Column David Ramos David Ramos I was hoping to use the RLS (UserPrincipalName) alongside a marker to drive a measure but I run into issues with the use of UPN when I got to the dynamic column. So I went down a 'selector' method - either by way of static table to return a number (for switch) on a selectedvalue against a slicer or a numeric parameter.
Reading your explanation - I guess the core question is - if a measure can't be used in the context of a column (or selectedvalue as a VAR in the calculated column) - would you know of a way to create a dynamic column here?
- MFelix
Super User
Sorry for the additional questions but can you explain a little bit better what you need to achieve?
You want to limit the data that the users sees or do you want to have it dynamic?
Can you make some example please?