Forum Discussion
Use Switch DAX to change between strings in a table visualisation
As fas as I am able to interpret you requirement, you are looking for a way to setup interaction between slicer and your table.
If there is no relationship between the two tables(NOXTestData & YetAnotherTest), you will have to associate the values separately
Create a measure to contain the selected value of the slicer like this:
Selected_Value = SELECTEDVALUE('Slicer Table'[Value])
Now create a measure to associate your table with slicer:
Dynamic value Calculation =
SWITCH(
TRUE(),
[Selected_Value] = "a", "Yourvaluecorresponding to a"),
[Selected_Value] = "b", "Yourvaluecorresponding to b"),
[Selected_Value] = "c", "Yourvaluecorresponding to c"),
and so on.....
)
Thanks for the reply. Ill try to be a bit clearer in my followup.
For my slicer I have a disconected table called Parameter table which has the following info in it.
| Code | Name |
| 1 | NO2 |
| 2 | NOX |
YetAnotherTest is my NO2 data and NOXTestData is my NOX data. They do have a relationship in a collumn called "NewID" which corresponds to the ID of the polygons on the map. I also already have a measure for the Parameter Table which is the same as you've used above:
Selected Measure = SELECTEDVALUES('Parameter Table'[code],1)
To switch between data values on the map I have a switch function that I put in the values section that is as follows:
All Pollution = SWTICH(
[Selected Measure],
1,SELECTEDVALUE('YetAnotherTest'[NO2_Mean],
2,SELECTEDVALUE('NOXTestData'[NOX_Mean]
)
This means on my slicer, I can switch between values on the map. I had orignally assumed the same dax above would also work with the table visualisation.
I then created some conditional columns that I had intended to use in the legend. I am using a table to do this. One has the category the value sits in, the other the corresponding colour hex code. These are made with conditional columns. So for example, a value with NOX = 22 sits in the LegName = 20-23.
When I drop these columns into a table without a switch it works as shown:
I need the table to switch out the columns between the NO2 and NOX tables as the catergoies and hex code colours are different depending on whether data from YetAnotherTest or NOXTestData are selected in the slicer.
Unless, I'm missing something, I'm not sure the above is the direct sollution to this issue. I was hoping there was a more direct function, like the one used for switching values in the map. Does the fact that the tables are related by NewID provide any alternatives?
- v-easonf-msft4 years ago
Community Support
Hi, Joe_Marangos
As a workaround, I think you could consider creating two separate table visualizations and then use the bookmark button to control which table visualization to show/hide.
Best Regards,
Community Support Team _ Eason