Forum Discussion

amikm's avatar
amikm
Helper V
4 years ago

Issue with conditional formatting for a table visual having measures in it

I am using the below table for reporting where the Product is coming from a product table and Q1Sales, Q2Sales,Q3Sales,Q4Sales are measures calculated using date and Sales Data

 

I need to do conditional formatting for each Product (each row)
Suppose for-
Apple if 1000-5000-> Red, 5001-8000-> Yellow, 8001+ -> Green
Samsung if 1000-5000-> Red, 5001-10000-> Yellow, 10000+ -> Green
OnePlus if 1000-4000-> Red, 4001-8000> Yellow, 8000+ -> Green
MI  if 1000-8000-> Red, 8001-10000-> Yellow, 8000+ -> Green

 

When I am trying to do this, I am not able to use multiple conditional formatting for the same measures. 

Can we use some DAX for this?

 

9 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi 

    Say for measure Q1 Sales

    Create flag say VarFlag= if(Product ="Apple" && Q1Sales>= 1000 && Q1Sales<= 5000, 0,

    if(Product ="Apple" && Q1Sales>= 5001 && Q1Sales<= 8000, 1,-1))

    Then use Colorcoding like below, it shoudl work 

     

    • amikm's avatar
      amikm
      Helper V

      thanks, Anonymous,
      Looks like varflag is a calculated column. But in my case varflag is grayed out when I am trying to use this column for conditional formatting, any reason for this? or it is grayed out because of I have created this column in cube ( tabular model)

  • Hi amikm 
    Please create one calculated column using this Dax 
    Background Colour. =
    iF(
        Product[Product] = Apple  > 1000-5000 ,"Red" ,
    IF(
        Product[Product] = Apple >  5001-8000 , "Yellow",
     IF(
        Product[Product] = Apple > 8001+ ,"Green")
    ))


    You can create the entire measure this way , put conditional formatting using field value

    • amikm's avatar
      amikm
      Helper V

      AlanP514  Anonymous 
      I have done that but the column is grayed out when I am using it while doing conditional formatting.
      My data source is azure analysis services. Is it the reason for grayed out?

  • jamilqpr's avatar
    jamilqpr
    Frequent Visitor

    First, decide and choose which variable will affect value color or background cell color, In this case you will choose sum of sale, and put your condition accordingly, 

    In my screen, I used as % value of total sales with the same format. I just want to show data bars in different colors accordingly by employee sales. This is how I formatted data barsIf i select nothing the data bars

    If I select year 2015 from slicer then data bars color

     

    Still have any question, I think you got it

  • Anonymous's avatar
    Anonymous
    Not applicable

    Create VarFlag as measure and use sum(varflag) to setup formatting 

  • Anonymous's avatar
    Anonymous
    Not applicable

    create varflag as measure and use sum(varflag) for conditional formatting

    • amikm's avatar
      amikm
      Helper V

      Hi Anonymous, Whenever I am trying to write the above Dax as a measure, It is giving me an error.
      And If we try to create multiple calculated columns for each product and apply them to each measure then it is also causing a circular dependency error.

      This means, I have created a column for Samsung and applied that column for conditional formatting for Q1Sales
      and when I am trying to create a column for Apply and applying that for conditional formatting of Q2Sales it is giving a circular dependency error

      Could you please share the pbix with measure and columns that can work for all measures (Q,Q2,Q3 and Q4)

      Aldo, whatever column I am creating inside the model and trying to use in Power Bi for conditional formatting is not working means no color formatting is applying. The calculated column is grayed out 

      • amikm's avatar
        amikm
        Helper V

        Anonymous , could you tell me what is wrong if my source is Azure analysis service as whatever column I am creating is getting grayed out?
        Also If you try to create calculate column, It will give you dependency error If you will start writing logic for Q2Sales