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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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