Forum Discussion

Mussaka's avatar
Mussaka
Helper I
3 years ago
Solved

Conditional formatting

Hi.

I should create a measure in DAX that simultaneously returns:

 

- if x < 0 then "over threshold"

- if x < 100 "close threshold"

- if x > 100 "within the threshold"

- if x < 50 (but only for CERTAIN people, for example "NY") "close threshold"

 

Where x is a measure that contains a "delta"

 

Did anyone understand me?

Thank you

 

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Refer the file shared by Anonymous  and make required changes as shown in the below images to obtain the results.

     


    Thank you. 
    If my answers helps you please mark it as solution.

     

12 Replies

  • Mussaka , Assume you have measure X

     

    Then a new measure

    Switch(true(),

    [X] < 0 , "over threshold" ,

    [X] < 100 , "close threshold" ,

    "within the threshold")

     

     

    Same way you can create color measure and use that in conditional formatting using field value option

     

    Switch(true(),

    [X] < 0 , "Red" ,

    [X] < 100 , "yellow" ,

    "green")

     

    Power BI Field Parameters — A Quick way for Dynamic Visuals: https://amitchandak.medium.com/power-bi-field-parameters-a-quick-way-for-dynamic-visuals-fc4095ae9afd
    Power BI Field Parameters- Measure Slicer and Axis/Dimension slicer: https://youtu.be/lqF3Wa1FllE
    Switch TOPN with Field Parameters: https://amitchandak.medium.com/switch-topn-with-field-parameters-299a0ae3725f
    Field Parameters- Conditional Formatting
    : https://amitchandak.medium.com/field-parameters-conditional-formatting-517aacc23fdf

     

    • Mussaka's avatar
      Mussaka
      Helper I

      The problem is that "x" is not a measure, but a column; this is because I need to use it in a filter:(

      The criteria must be the following:

      - if (name of the table[measure]<0, "over threshold"

      - if (name of the table[measure]<100, "close threshold"

      - if (name of the table[measure]<50, (only for a determined number of persons, for example "english")"close threshold"

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Mussaka ,

    I have created a simple sample, please refer to it to see if it helps you.

    Create a measure.

    result = IF([valuemeasure]<0,"over threshodl",IF([valuemeasure]>0&&[valuemeasure]<100,"close threshold",IF([valuemeasure]<50&&MAX('Table'[country])="english","close threshold",BLANK())))

    How to Get Your Question Answered Quickly 

     

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

     

    Best Regards
    Community Support Team _ Polly

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Mussaka's avatar
      Mussaka
      Helper I

      I have to create a slicer with 3 boxes: "over threshold", close threshold", "within the threshold" and I have 4  categories of people, "Chinese", "English" “italian”, “Spanish”. In the first box there must be all the people (Chinese, English, Italian e Spanish ) which have a negative number as a result of a measure (which is a delta). In the second box: if "Chinese" from 0 to 50 (this because their threshold is 100), if other countries from 0 to 100 (the threshold is 200); in the third box all the other possibilities except those just described.

      If correct, the slicer will return in a table only the names of the people in the 3 categories I mentioned above. I hope I have been clear enough.

      Thanks in any case for the help you will know give me.

      Best regards

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Mussaka ,

        Could you please provide some sample data and your desired output with more details?

         

        How to Get Your Question Answered Quickly 

         

        Best Regards
        Community Support Team _ Polly

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.