March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I'm wondering if it is possible to create a dynamic text field in DAX that changes value based on a SWITCH statement. I know this is possible to do with calculated columns, but this will not be dynamic since calculated columns are computed at load time. I would like the user to be able to select a value in a slicer and the text field would dynamically change its value to the respective column in the dataset (e.g. select "Country" and the field would be [Country], select "Continent" and the field would be [Continent]).
If I'm understanding your request correctly, you need:
Selected region = IF(ISFILTERED(Disconnected Table [Field]), SELECTEDVALUE(Disconnected Table [Field]), "All Areas"),
or if you prefer to show nothing change "All Areas" to BLANK()
Proud to be a Super User!
Paul on Linkedin.
Thanks. Let me be more clear. I have two tables, one is the disconnected table, Table A, with one column containing the four values "Project", "Continent", "Sub Region", and "Country". The other table, Table B, is as shown below.
I want to have a field in Table B that changes dynamically based on the selected value from Table A. For example if "Project" is selected in Table A, then the field in Table B would contain the values from the [Project] column.
Hi @soarryan
To be dynamic, it should be a measure. The problem is that a measure should be aggregated and is expected to return only one value, so it is possible to return e.g. First or Last value in a field, or Count of a field. It cannot display multiple values at the same time.
Here is one example
Measure = SWITCH(SELECTEDVALUE('Table A'[Type]),"Project",MAX('Table B'[Project]),"Country",MAX('Table B'[Country]),"Continent",MAX('Table B'[Continent]),"Sub Region",MAX('Table B'[Sub Region]))
Another example
Measure 2 = SWITCH(SELECTEDVALUE('Table A'[Type]),"Project",COUNT('Table B'[Project]),"Country",COUNT('Table B'[Country]),"Continent",COUNT('Table B'[Continent]),"Sub Region",COUNT('Table B'[Sub Region]))
You can see that I use Max and Count to aggregate every field in the measure. You can try using Values() to get the values in a field but when you put it into a visual, it will display an error saying "A table of multiple values was supplied where a single value was expected." If you want to display all values, you can use CONCATENATEX to concatenate the values in a column. What do you hope to do after getting the values in a column?
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
@soarryan , You can enable Q&A . and post that you can add the measures to your text box, you will get a + value option
You can have measure like selectedvalue(Table[Country]) , Sum(Table[Sales]) etc and use that
Thanks for the reply.
I'm not looking to change a field in a text box, rather a text column in the dataset.
For example, the table below. I've created a disconnected table with only the text values "Project", "Continent", "Sub Region", and "Country". I have a slicer on the dashboard that allows the user to select one of these 4 text values. What I'm trying to do is have a text field that changes based on what the user selects in the slicer using a SWITCH statement. E.g. SWITCH(SELECTEDVALUE([Disconnected Table Field]), "Project", [Project], "Continent", [Continent], ...)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
125 | |
85 | |
69 | |
54 | |
45 |
User | Count |
---|---|
204 | |
106 | |
98 | |
65 | |
54 |