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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
vnqt
Helper V
Helper V

Color the measure with condition

Hi,

 

I have 2 tables : 

 Name

 

NameModelType
Name 1MonoLR
Name 2MonoFA
Name 3MonoLR
Name 4MonoFA
Name 5MonoLR
Name 6MonoFA
Name 7MonoLR
Name 8MonoWI
Name 9BisiteWI
Name 10BisiteWI
Name 11BisiteWI
Name 12BisiteWI
Name 13BisiteLR
Name 14BisiteFA
Name 15BisiteLR
Name 16BisiteFA

 

Number 

NameUSEDFREE
Name 18086
Name 109095
Name 115095
Name 125095
Name 134040
Name 144040
Name 154040
Name 164040
Name 29085
Name 35555
Name 485100
Name 55095
Name 65095
Name 75095
Name 85095
Name 99095

 

The 2 tables have 1 - 1 relation

I have a measure to count name 

 

Measure = var _total = CALCULATE(DISTINCTCOUNT(Name[Name]), Name[Model] = "Mono" &&  (Name[Type] = "WI" || Name[Type] = "LR"))

var _cf = CALCULATE(DISTINCTCOUNT((Name[Name]), Name[Model] = "Mono" && (Name[Type] = "WI" || Name[Type] = "LR" ), FILTER(Number,  Number[USED]<= 85 ) , FILTER(Number[FREE] <=85), USERELATIONSHIP( Number[Name],  (Name[Name] )))

RETURN _cf &" / "&_total
RESULT : 1/  
Name 3  / Name 1, Name 3, Name 5, Name 7, Name 8
 
NameUSEDFREE
Name 18086
Name 35555
Name 55095
Name 75095
Name 85095
There are 4 differences, IF one of these 4 Names having: 
 -  85 <MAX (USED or FREE)   < = 90    THEN  yellow
 - 90< MAX(USED or FREE) <= 95   THEN  orange
-  MAX(USED or FREE) > 95    THEN  red
In this case, the color of the measure should be orange (90< MAX(USED or FREE) <= 95)
Thank you in advance for your help.
Tg 
 
1 ACCEPTED SOLUTION

@vnqt , 
Understood, use the below measure to do that. 

manikumar34_0-1742223977090.png

color1 =
VAr val=
CALCULATE(MAX(MAX(Number[USED]),MAX(Number[FREE])),'Name'[Model] = "Mono" &&  ('Name'[Type] = "WI" || 'Name'[Type] = "LR"))
RETURN
val




If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




View solution in original post

10 REPLIES 10
manikumar34
Solution Sage
Solution Sage

@vnqt 
color measure given by dane does work. What are you exactly looking for?

manikumar34_0-1742215291465.png

 





If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




Hi, 

I created the measure color of @danextian but it doesn't work. 

I would like to create a measure to color the card : 

RESULT : 1/  
Name 3  / Name 1, Name 3, Name 5, Name 7, Name 8
 
NameUSEDFREE
Name 18086
Name 35555
Name 55095
Name 75095
Name 85095
There are 4 differences, IF one of these 4 Names having: 
 -  85 <MAX (USED or FREE)   < = 90    THEN  yellow
 - 90< MAX(USED or FREE) <= 95   THEN  orange
-  MAX(USED or FREE) > 95    THEN  red
In this case, the color of the measure should be orange (90< MAX(USED or FREE) <= 95)
 
Thank you 

@vnqt ,
I can see it is working, could you please share what is your exact requirement?

manikumar34_0-1742221332359.png

 





If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




Hi, 

 

I would like to color the card with the color 

 

vnqt_0-1742221836259.png

And the rule of color is: 

The card is orange because the value USED or FREE of the following name (Name 1,Name 5, Name 7, Name 8  )   > 90 AND <=95
 
 -  85 <MAX (USED or FREE)   < = 90    THEN  yellow
 - 90< MAX(USED or FREE) <= 95   THEN  orange
-  MAX(USED or FREE) > 95    THEN  red
 
Thank you

@vnqt , 
Understood, use the below measure to do that. 

manikumar34_0-1742223977090.png

color1 =
VAr val=
CALCULATE(MAX(MAX(Number[USED]),MAX(Number[FREE])),'Name'[Model] = "Mono" &&  ('Name'[Type] = "WI" || 'Name'[Type] = "LR"))
RETURN
val




If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




Thank you for your help . 

danextian
Super User
Super User

Hi @vnqt 

 

Try this:

color =
VAR _used =
    CALCULATE (
        SELECTEDVALUE ( Number[USED] ),
        USERELATIONSHIP ( 'Name'[Name], 'Name'[Name] )
    )
VAR _free =
    CALCULATE (
        SELECTEDVALUE ( Number[FREE] ),
        USERELATIONSHIP ( 'Name'[Name], 'Name'[Name] )
    )
VAR _max =
    MAX ( _used, _free )
RETURN
    SWITCH ( TRUE (), _max > 95, "red", _max > 90, "orange", _max > 85, "yellow" )




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.

Hi, sorry I didn't give enough info in the first post, I have added some more info. thank you for your help

vojtechsima
Super User
Super User

@vnqt 

try something simialr to this (create measure for USED/FREE or use MAX etc, depends how yo will display in visual):

SWITCH(TRUE(),
[USED] || [FREE] > 85, "yellow",
[USED] || [FREE] > 90, "orange",
[USED] || [FREE] > 95, "red"
)

 

 

Hi, I have justed added some more info, hope you could help. Thank you.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors