Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi
Colour formatting is needed – red for negative, and green for positive in DAX
Name | 2019 | 2020 | vs LY | vs LY % |
A | 61 | 20 | -41 | -41% |
B | 5 | 8 | 3 | 10% |
I know how to do it in power bi but I need it in DAX code
Solved! Go to Solution.
Hi @javieregh,
you still need to set the color measure in the "Conditional Formatting" options of the visual (as described above).
As @selimovd stated before, it´s not possible to do the formatting entirely in DAX. You still need to do some settings in the visual.
Did this answer your question? Mark my post as a solution!
Hey @javieregh ,
the conditional formatting is part of the visual.
DAX itself will just give you the values, you cannot format in DAX, you can just use the formatting options of the visual.
Hi @javieregh,
you won´t totally get away without visual options, but you can go as far as defining the HEX-Value of a color in a Measure (so the Measure returns the HEX-Value) and then use this Measure to color the field.
First of all a I created a simple Measure that evaluaets if "vs LY" is positiv or negativ. For positiv it returns the hex-Value of green, for everything else it returns red:
color =
var _good = "#00FF00" // green
var _bad = "#FF0000" // red
RETURN
IF([vs LY] >= 0, _good, _bad)
Now we can go ahead and select this Measure in the visual options under "Conditional Formatting" -> "Font Color" (or whatever you want to change) -> "Advancend Controls" (If the window doesn´t open from itself) -> Change "Format by" to "Field value" -> under "Based on field" select your previously created (in this case "color") Measure
Hope this helps.
Best regards,
Markus
Did this answer your question? Mark my post as a solution!
Thanks Markus for you email
The results print this
not value in color
Hi @javieregh,
you still need to set the color measure in the "Conditional Formatting" options of the visual (as described above).
As @selimovd stated before, it´s not possible to do the formatting entirely in DAX. You still need to do some settings in the visual.
Did this answer your question? Mark my post as a solution!
@Markus_Re @selimovd Thanks so much Markus and Denis I saw the variable was format to Percentage I changed to standard and now working fine ... All Good
User | Count |
---|---|
21 | |
14 | |
11 | |
7 | |
5 |
User | Count |
---|---|
23 | |
23 | |
20 | |
15 | |
10 |