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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
SabineOussi
Skilled Sharer
Skilled Sharer

Dynamic Text

Hello,

 

Is there a way that I can create a dynamic text within the text box?

 

In other words, let's say I want to display the following:

There are @numberoftickers submitted by @numberofusers and managed by @numberofadmins 

@numbers will be a count of certain fields.

 

I know that I can create a card of the desired count and a text box with a specified space and put them on top of each other so that they appear as they're written in one sentence.

 

But is therer a better way to do it? Like sort of a hyperlink to columns?

 

Thanks,

Sabine O.

1 ACCEPTED SOLUTION
SqlJason
Memorable Member
Memorable Member

What you can do is to create a measure like 

TextMeasure = "There are " +  [numberoftickers] + " submitted by " + [numberofusers] + " and managed by " + [numberofadmins]

 

Now you can place this measure in a text box and that should show the desired result. Using text based measures is a handy technique in scenarios like this. 

View solution in original post

14 REPLIES 14
koplis
Frequent Visitor

This feature was added in mid 2021

You can create dynamic text within text boxes without any coding or extra variables.

Someone talks about it here... https://www.wiseowl.co.uk/blog/s2887/text-box.htm

This discussion is still the number one Google result so thought I'd provide an update 🙂

koplis_0-1669759522320.png

 

SemG
Frequent Visitor

For everyone that's searching for this. I have created filling in parts of text boxes dynamically as an idea on ideas.powerbi.com. Please vote on it so that we can have this useful feature. Link below.

 

https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/33374140-using-measures-to-dynami...

MrDataGeek
New Member

@SqlJason how do you set a textbox to the value of a measure? I was able to create a measure that returns a dynamic title using your method but I don't know how to set a textbox a measure. I was able to do so using the "card" visualization but I don't want to use that visualization because it uses the name of the measure as a default title. 

@MrDataGeek it is a card visualization and not a textbox. You can turn off the category label, turn on the title and put the title text you want.

Thanks @SabineOussi! I figured that out last night and I was about to update my question before I saw your response. I did not initially think to turn off the "category label". I appreciate your help!

SqlJason
Memorable Member
Memorable Member

What you can do is to create a measure like 

TextMeasure = "There are " +  [numberoftickers] + " submitted by " + [numberofusers] + " and managed by " + [numberofadmins]

 

Now you can place this measure in a text box and that should show the desired result. Using text based measures is a handy technique in scenarios like this. 

Hi But how can we pass it to text ?

The problem with using a card is that you lose the control over font over individual segments. For eg: if I wanted to display the measure value in bold and different color from rest of the text, or go to next line, I cant do that.

So basically, being able to concat text and measure directly in text box would be good.

The other problem with using a card is that you lose all formating capabilities. (or at least to the best of my knowledge).

 

I have not been able to left justify the text in a card. 

Anonymous
Not applicable

Chris Webb has blogged about a fantastic solution that listens to slicer values to dynamically create a title.  Very similar solution using a card with no category that "sits on top of" of chart, but a little more robust.

 

@SqlJason, & is the concatenation operator in DAX; + is not overloaded as in SQL.

 

As an additional point, depending on the measure being used to provide the numeric portion of this string, you may find a need for FORMAT(), which allows you to use a format string to alter the display of a numeric or date value.

My bad, I forgot to test it before posting :).... Yes you will have to use the & operator as well as FORMAT() based on your needs as @greggyb mentioned.

Yes, I'm aware about the language, thanks.

 

I was just hoping to have a more direct solution.

HarrisMalik
Continued Contributor
Continued Contributor

@SabineOussi as far as I know text expressions are not yet available but as you mentioned you can do some workarounds.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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