cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

## 2 different formulas for conditional formatting based on different values

*I attached a sample file of data if looking at that before hand helps (it is very simple for privacy reasons, if you need more info i can add more

Table:

 ID classification value 1 focus 4 1 non-focus 3 1 non-focus 5 1 non-focus 2 1 non-focus 4 1 non-focus 3 2 focus 4 2 focus 1 2 focus 2 2 non-focus 2 2 non-focus 3 2 non-focus 4 2 non-focus 4 3 focus 4 3 focus 5 3 focus 3 3 non-focus 4 3 non-focus 2 3 non-focus 1 3 non-focus 1 3 non-focus 3

So I am using a matrix for this data and want to add conditional formatting which I know how to do but struggling on changing it based on certain factors.

While looking at the data you can see where ID = 1, there is only one focus in that section. When there is just one focus i want the conditional formatting to be if it is .3 or more than the focus then green, if .03 lower then red. This is very simple and would just be something like :

if average(query1[value]) .3 >= focus, 1, 2 and then i would do the conditional formatting as rules based on this measure and so on

Then the second part is, in the sample data where ID = 2 or ID = 3, there are multiple focus's. When there is multiple focus's in an ID, I want the formatting to be the thing basically but .3 > than the average value for the ID rather than the focus. So this is basically the same formula but based on the averge vs the focus.

My question is, how can I do this in the conditional formatting/ the measure for the conditional formatting. I dont know when an ID is going to have more than 1 focus so I can't just do IF ID = 3 then .3>averageid.

I know how to explain it in words just not in a formula. Basically if an ID has > 1 focus then formula1, if not then formula2. If you have any tips on how to accomplish this, that would be great! Thanks

3 REPLIES 3
Community Support

Hi @uxorise3424 ,

``````Measure =
VAR __CurrentID = MAX ( 'Table'[ID] )
VAR __FocusCount =
CALCULATE (
COUNTROWS ( 'Table' ),
'Table'[ID] = __CurrentID,
'Table'[classification] = "focus"
)
VAR __Result =
IF(__FocusCount=1,<condition1>,<condition2>)
RETURN
__Result``````

Best Regards,
Gao

Community Support Team

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Frequent Visitor

thanks i feel like this could work but i am having a small issue with it. So i have my two formulas for my conditional formatting and they work perfect individually but when I put them in this formula you gave me, they both completely change and not working right. I tried using the actual measure in the part where you put <condition1> and 2 and that didn't work. After that I used the formula from my measures and created a var in your formula and then used that in the condition and it didn't work either. Do you know why this would be?

edit: i realized it has to do with the count rows calcuation and it is always returning the secondc condition. i am looking into why this is happening

Super User

Your data is missing an index column.  Power BI will automatically aggregate unless you specifically tell it not to.

With the index the identification of your thresholds becomes easy.

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

#### Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors
Top Kudoed Authors