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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
ustpowbi
New Member

Possible to change font color of ONLY a dynamic value in a static text string?

I'm very new to power BI and am working with a dashboard passed on to me by a contactor who was a power user.

 

Is it possible to contionally change the font color of a dynamic % value surrounded by other static text that should be black. All of it is part of a text measure. A slicer controls the value. Desired output below:

 

Text text text 3% text text text. 

Text text text -16.08% text text text. 

 

The measure is currently defined like this: BParamText = "Text text text " & BParam[BParam Value] * 100 & "% text text text." 

 

I've tried conditonal formatting but that obviously turns the whole text string green or red, not just the value.

 

I've also tried dividing everything into 2 separate elements, just the value by itself (conditonally formatted) with a plain text box around the value, but that creates weird gapping/overlapping when the numbers are long like -20.08% or short like 8%. Screen shots:

ustpowbi_0-1636649124396.png

ustpowbi_1-1636649163393.png

 

Any ideas? Thank you!!!

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @ustpowbi 

 

Download example PBIX file

 

If you use this visual HTML Content - Custom Visual for Power BI (html-content.com) you can do it.

 

After installing the visual, add one to the page.

 

I've set up a dummy measure

 

 

HTML Measure = 

VAR _Value = SELECTEDVALUE('DataTable'[Value])

VAR _StartText = "There are <style> span "

VAR _EndText = "</span> widgets in the selected category."

RETURN

IF ( _Value > 0, _StartText & "{color:#48e21a;} </style><span>" & _Value & _EndText, _StartText & "{color:#ff0000;} </style><span>" & _Value & _EndText )

to work with this data

html-text.png

 

Text color is controled by the hex color code e.g. #ff00000.

 

You'll need to modify your code to suit your needs.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, I need to export the Power Bi file to ppt in Power BI Service. But since html content custom visual does not allow that, I have an error wherever I have used it in the page. Is there any workaround for this?

Hi @Anonymous 

 

Please start a new topic for this issue.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

Hi @ustpowbi 

 

Download example PBIX file

 

If you use this visual HTML Content - Custom Visual for Power BI (html-content.com) you can do it.

 

After installing the visual, add one to the page.

 

I've set up a dummy measure

 

 

HTML Measure = 

VAR _Value = SELECTEDVALUE('DataTable'[Value])

VAR _StartText = "There are <style> span "

VAR _EndText = "</span> widgets in the selected category."

RETURN

IF ( _Value > 0, _StartText & "{color:#48e21a;} </style><span>" & _Value & _EndText, _StartText & "{color:#ff0000;} </style><span>" & _Value & _EndText )

to work with this data

html-text.png

 

Text color is controled by the hex color code e.g. #ff00000.

 

You'll need to modify your code to suit your needs.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.