Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

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 
 
  • Anonymous , 
    Understood, use the below measure to do that. 

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

10 Replies

  • Anonymous 

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

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

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

  • Hi Anonymous 

     

    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" )
    
    • Anonymous's avatar
      Anonymous
      Not applicable

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

  • Anonymous 
    color measure given by dane does work. What are you exactly looking for?

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      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 
      • manikumar34's avatar
        manikumar34
        Icon for Solution Sage rankSolution Sage

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