Forum Discussion

Soniar's avatar
Soniar
Regular Visitor
3 years ago

Conditional row formatting based on column total by category

Hello,

I would like to create a conditional formatting of my following datas:

The result has to be red color if the % in the row is < of the related colum total. (Ex. for actuators less then 32.57% valve less then 32.15) the values are %tr of sales amount

any idea?

thanks.

Sonia

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Soniar ,

    You can first use measure to find the Total value, and then use Value to compare.

    In my data, Total represents the average of each group.

    Here are the steps you can follow:

    1. Create measure.

    color =
    IF(
        MAX('Table'[Amount])<
     DIVIDE(
    SUMX(FILTER(ALL('Table'),'Table'[Group]=MAX('Table'[Group])),[Amount]),
    CountX(FILTER(ALL('Table'),'Table'[Group]=MAX('Table'[Group])),[Amount]))
    &&HASONEVALUE('Table'[Region])=TRUE()
        ,"red")

    2. [Measure] – Conditional formatting – Background color.

     

    3. Result:

     

    Best Regards,

    Liu Yang

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

    • Soniar's avatar
      Soniar
      Regular Visitor

      Hello Liu,

      Thanks for your reply

      I followed your instruction but the result is not correct

      I created the Measure color as you suggest 

      color =
      IF(
          MAX('sales_totale'[UBLNAM])<
       DIVIDE(
      SUMX(FILTER(ALL('sales_totale'),'sales_totale'[MMITCL]=MAX('sales_totale'[MMITCL])),[UBLNAM]),
      CountX(FILTER(ALL('sales_totale'),'sales_totale'[MMITCL]=MAX('sales_totale'[MMITCL])),[UBLNAM]))
      &&HASONEVALUE('sales_totale'[OKCUNM])=TRUE()
          ,"red")
      I don't know if the problem is due to the fact that family and region are not contained in the same table.
      I used MMITCL in the measure that is related to the family table and OKCUNM that is related to the customer table where there is the region.
      As you can see in the screenshot the red color is not applied correctly.
      thanks
      Sonia