Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
I have the following data:
Sort Order | Item
1 |Product1
2 |Product2
3 |Product3
4 |Product4
Item | Quantity
Product1 | 213
Product2 | 145
Product3 | 312
Product4 | 274
I would like to show the data as a bar chart. The bar for Product3 should be Green if it is greater than Product2, Red if it's not. The bar for Product2 should be Green if it's greater than Product1, Red if it's not. The other bars should be some other color like Blue.
I've tried a number of different combinations of measures but I just can't seem to figure this one out. I feel like I know how to do it but the actual implimentation is beyond me.
EDIT: Included Sorting Table...
Solved! Go to Solution.
You must have more complex data table, but for this sample try following:
1. Create a conditional measure:
Measure =
Var p1 = CALCULATE(SUM('Table (2)'[Quantity]),FILTER('Table (2)',[Item]="Product 1"))
var p2 = CALCULATE(SUM('Table (2)'[Quantity]),FILTER('Table (2)',[Item]="Product 2"))
var p3 = CALCULATE(SUM('Table (2)'[Quantity]),FILTER('Table (2)',[Item]="Product 3"))
var p4 = CALCULATE(SUM('Table (2)'[Quantity]),FILTER('Table (2)',[Item]="Product 4"))
Return
SWITCH(TRUE(),
p3>p2,1,
p2>p1,1,
0)
2. Set default color to Red
3. Rule with the measure
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
@pabeader
I believe the real dataset you have should be more detailed than this. Si there a numeric value associated with each Product Name like a sort order which will help identify the category value to avoid hard coding it?
________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
The order that they appear in, doesn't really matter. The different Products could appear anywhere in the chart, what matters is their relationship to each other. Product3 > Product2 makes Product3 bar Green otherwise Red. Product2 > Product1 makes Product2 bar Green otherwise Red.
You must have more complex data table, but for this sample try following:
1. Create a conditional measure:
Measure =
Var p1 = CALCULATE(SUM('Table (2)'[Quantity]),FILTER('Table (2)',[Item]="Product 1"))
var p2 = CALCULATE(SUM('Table (2)'[Quantity]),FILTER('Table (2)',[Item]="Product 2"))
var p3 = CALCULATE(SUM('Table (2)'[Quantity]),FILTER('Table (2)',[Item]="Product 3"))
var p4 = CALCULATE(SUM('Table (2)'[Quantity]),FILTER('Table (2)',[Item]="Product 4"))
Return
SWITCH(TRUE(),
p3>p2,1,
p2>p1,1,
0)
2. Set default color to Red
3. Rule with the measure
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
Actually, the datatable is that simple. It's the result of a number of aggregations and work on the SQL backend.
User | Count |
---|---|
85 | |
74 | |
71 | |
67 | |
56 |
User | Count |
---|---|
96 | |
94 | |
92 | |
78 | |
71 |