Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
*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
Hi @uxorise3424 ,
Please try:
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
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
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.
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
30 | |
15 | |
11 | |
10 | |
9 |