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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
mcijerry
New Member

Color a specific string inside a measure for use in a Textbox

Using the measure below to dynamically reflect the logon user in a textbox.  I would also like to color only the USERNAME() value returned BLUE

Any thoughts?

Measure

Get Username in Title = "All Registered Endpoints for Employee or Manager: " & USERNAME()
1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@mcijerry Add a text box to your Power BI report where you want to display the message.

 

In the text box, insert the measure you created. This will display the full message including the username.

 

Since DAX does not support text formatting, you will need to use Power BI's conditional formatting to color the username. Unfortunately, Power BI does not support conditional formatting within text boxes directly. However, you can use a workaround by creating a separate measure for the username and then using a card visual to display and format it.

Create a new measure for the username:

Username Only = USERNAME()

 

Add a card visual to your report and set its value to the Username Only measure.

Use the formatting options in the card visual to set the text color to blue.

 

Position the card visual with the username next to the text box so that it appears as part of the same sentence. This way, the username will be displayed in blue while the rest of the text remains in the default color




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

3 REPLIES 3
danextian
Super User
Super User

Hi @mcijerry 

 

Measures cannot be partially conditionally formatted. You can however use a DAX-generated SVG image that partially colors a text.

danextian_0-1742557043055.png

Please see the attached sample pbix.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
bhanu_gautam
Super User
Super User

@mcijerry Add a text box to your Power BI report where you want to display the message.

 

In the text box, insert the measure you created. This will display the full message including the username.

 

Since DAX does not support text formatting, you will need to use Power BI's conditional formatting to color the username. Unfortunately, Power BI does not support conditional formatting within text boxes directly. However, you can use a workaround by creating a separate measure for the username and then using a card visual to display and format it.

Create a new measure for the username:

Username Only = USERNAME()

 

Add a card visual to your report and set its value to the Username Only measure.

Use the formatting options in the card visual to set the text color to blue.

 

Position the card visual with the username next to the text box so that it appears as part of the same sentence. This way, the username will be displayed in blue while the rest of the text remains in the default color




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






This worked great.  I created another text box (referenced the GETUSERNAME Measure), resized it appropriately and turned off backgroud color----so it blended in perfectly with the textbox under it.

Thank you Bhanu!

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.