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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
MathieuF
Helper III
Helper III

Conditional formatting on part of cell

Good morning,
In a table, I use concatenation to group 3 values in the same cell.
I would like to be able to change the color of just one of the 3 values based on it.
How to do ?
Thanks in advance.
Mathieu

 

DAX: 

DeltaSat (Formatage) =
FORMAT([DeltaSat (Agent)],"Percent") &
" | " & FORMAT([DeltaSat (Equipe)],"Percent") &
" | " & FORMAT([DeltaSat (Compétence)],"Percent")
1 ACCEPTED SOLUTION

You can use a HTML visual and watch this video: 

UpVote the idea here

View solution in original post

9 REPLIES 9
MathieuF
Helper III
Helper III
_elbpower
Resolver III
Resolver III

Use Tabulator PowerBI Visual
You can use this table in your report and just create a HTML measure like i have sent above. This is working fine,

MathieuF
Helper III
Helper III

@_elbpower 

 

I am testing the 2nd solution

MathieuF_0-1698219944550.png

 

_elbpower
Resolver III
Resolver III

can you please share your measure code here

Here is what I did to test :

DeltaSat (Formatage) =
"<span style='color:red'>" &        FORMAT([DeltaSat (Agent)],"Percent") & "</span>"&
" | " & FORMAT([DeltaSat (Equipe)],"Percent") &
" | " & FORMAT([DeltaSat (Compétence)],"Percent")
_elbpower
Resolver III
Resolver III

Assuming you want to change the color of the value from [DeltaSat (Agent)] based on a condition, you can use the following DAX code:

 

DeltaSat (Formatage) =
VAR AgentColor = IF([DeltaSat (Agent)] < 0.2, "Red", "Black")  -- Define your condition here
VAR AgentText = FORMAT([DeltaSat (Agent)], "Percent")
VAR EquipeText = FORMAT([DeltaSat (Equipe)], "Percent")
VAR CompétenceText = FORMAT([DeltaSat (Compétence)], "Percent")
RETURN
    SWITCH(
        TRUE(),
        [DeltaSat (Agent)] < 0.2, "<span style='color:" & AgentColor & "'>" & AgentText & "</span> | " & EquipeText & " | " & CompétenceText,
        TRUE(), AgentText & " | " & EquipeText & " | " & CompétenceText
    )

 

In this code, we first define a variable AgentColor that checks a condition for [DeltaSat (Agent)] and sets the color to "Red" if the condition is met, otherwise "Black". You can change the condition as per your requirement.

Then, we use the SWITCH function to conditionally format the text in the DeltaSat (Formatage) column. If the condition is met, it wraps the [DeltaSat (Agent)] value in an HTML span element with the specified color.

Make sure you replace the condition in IF with your specific criteria for changing the color, and adjust the color and formatting as needed. This code assumes that you are working with a table that can interpret HTML styling for text color.

 

Hello @_elbpower 
Thanks for your return.
Are you sure the HTML code works in DAX, I tested it, but without success?

MathieuF_0-1697808948165.png

 

Mathieu

You can use a HTML visual and watch this video: 

UpVote the idea here

@_elbpower  It's super complicated 😄

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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