cancel
Showing results 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

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 ?
Mathieu

DAX:

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

You can use a HTML visual and watch this video:

UpVote the idea here

9 REPLIES 9
Helper 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,

Helper III

I am testing the 2nd solution

Resolver III

Helper III

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")
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.

Helper III

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

Mathieu

Resolver III

You can use a HTML visual and watch this video:

UpVote the idea here

Helper III

@_elbpower  It's super complicated 😄