Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
soarryan
Frequent Visitor

Creating a dynamic text field in DAX

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]).

5 REPLIES 5
PaulDBrown
Community Champion
Community Champion

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()





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

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.

 

soarryan_0-1649951960586.png

 

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]))

vjingzhang_0-1650593962818.png

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]))

vjingzhang_1-1650594137488.png

 

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.

amitchandak
Super User
Super User

@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

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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], ...)

 

soarryan_0-1649950892230.png

 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.