Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi
I have a bar chart that needs to show colour changes depending on whether the values have increased or decreased from the previous Month.
For example -
I have a calculated field called MOM Fruit
Jan = 19
Feb = 26
Mar = 14
Apr = 6
May = 8
So, I need Feb to be Red, Mar Green, Apr Green and May Red
Any help would be great
Solved! Go to Solution.
Hi @kevbrown1980 ,
I created some data:
Here are the steps you can follow:
1. Create measure.
Color =
var _current=CALCULATE(SUM('Table'[MOM Fruit]),FILTER(ALL('Table'),MONTH('Table'[Date])=MONTH(MAX('Table'[Date]))))
var _last=CALCULATE(SUM('Table'[MOM Fruit]),FILTER(ALL('Table'),MONTH('Table'[Date])=MONTH(MAX('Table'[Date])-1)))
var _if=
IF(
_last=BLANK(),_current,_last)
var _su=
_current - _if
return
SWITCH(
TRUE(),
_su=0,"blue",
_su>0,"red",
_su<0,"green")
2. Click Visual - Format - Data colors -- fx
3. Enter the Default color interface.
Format style – Field value
What field should we base this on – [color]
4. 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
Hi @kevbrown1980 ,
I created some data:
Here are the steps you can follow:
1. Create measure.
Color =
var _current=CALCULATE(SUM('Table'[MOM Fruit]),FILTER(ALL('Table'),MONTH('Table'[Date])=MONTH(MAX('Table'[Date]))))
var _last=CALCULATE(SUM('Table'[MOM Fruit]),FILTER(ALL('Table'),MONTH('Table'[Date])=MONTH(MAX('Table'[Date])-1)))
var _if=
IF(
_last=BLANK(),_current,_last)
var _su=
_current - _if
return
SWITCH(
TRUE(),
_su=0,"blue",
_su>0,"red",
_su<0,"green")
2. Click Visual - Format - Data colors -- fx
3. Enter the Default color interface.
Format style – Field value
What field should we base this on – [color]
4. 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
Hello @kevbrown1980.
Assuming you have a date table, you could create a measure using this pattern:
Bar formatting =
VAR PriorMonthMOMFruit =
CALCULATE ( SUM ( 'Table'[MOM Fruit] ), DATEADD ( 'Date'[Date], -1, MONTH ) )
VAR CurrentMonthMOMFruit =
CALCULATE ( SUM ( 'Table'[MOM Fruit] ) )
VAR Result =
IF ( ( CurrentMonthMOMFruit - PriorMonthMOMFruit ) > 0, "Green", "Red" )
RETURN
ResultNote that you can replace "Green" and "Red" with hex values if you want to fine-tune the shade of the colour.
Then, select your bar chart, and in the visualization pane, under Data colors, click the "fx" button:
On the next screen, under the "Format style" drop-down at the top, choose "Field value".
Then, under "What field should we base this on", choose the measure you created above.
Your results should look something like this:
I created a .pbix file here that you can download if it is helpful.
-Steve
@kevbrown1980 , create a measure like this example and use it conditional formatting using field value option
Colour =
SWITCH(TRUE(),
max('Table'[Month]) = "Feb", "red",
max('Table'[Month]) = "Mar", "Green",
max('Table'[Month]) = "Apr", "Green",
max('Table'[Month]) = "May", "Red",
//keep on adding
"green")
How to do conditional formatting by measure and apply it on pie?: https://youtu.be/RqBb5eBf_I4
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 43 | |
| 39 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 63 | |
| 32 | |
| 30 | |
| 23 |