Forum Discussion
Conditional Formatting a Line Chart in Power BI
I'm not sure if this is possible in Power BI, but want to try workarounds
My requirement:
For my data given below, I want to color Actuals with a different color and my Non Actuals with a differnt color on a line chart.
| Date | Value | Type |
| 1/1/2021 | 100 | Actuals |
| 1/2/2021 | 200 | Actuals |
| 1/3/2021 | 300 | Actuals |
| 1/4/2021 | 400 | Actuals |
| 1/5/2021 | 500 | Actuals |
| 1/6/2021 | 640 | Forecast 1 |
You can use two measures instead of conditional formatting: one measure for Actuals and the other for the Forecast values (this measure must include the actual values to avoid the blank space in the chart). so:
Actuals = SUM(Table [Actuals]
Forecast = SUM(Table [Forecast]) + [Actuals]Place both measures in the values bucket and then format each measure to your liking:
7 Replies
- kleharHelper V
@PaulDBrown tagging you since you have context
- PaulDBrownCommunity Champion
Here are two options:
1) Since the default line chart doesn' allow conditional formatting, you can hack it by creating a bar chart first, adding the conditional formatting and then changing it to a line chart.
I've created this measure to format the chart:
Line Colour = IF(MAX('Table'[Filter/Type]) = "Actuals", 1, 2)2) Use two measures for the line chart. The measure you already have for the forecast and another for "Actuals"
Actuals = CALCULATE([Sum Value],'Table'[Filter/Type] = "Actuals")Add both measures to the Values bucket and then format each meaure to your liking:
- kleharHelper V
Pragati11 PaulP
While your bar chart solution is quite intuitive, I'm using first the traditional line chart solutionHowever I get a gap and want the lines to be joined on my actual dataset.
If this doesn't work I'll like to try the bar chart approach.
However what measure should i use in the bar chart in the value column, since conditional formatting requires me to have only 1 value.
- AnonymousNot applicable
Hi Pragati11 sorry to biggie back on this but it kinda aligns.
I have a date axis, 1 line in my line graph and able to see forecast in my analytics. However it displays pff and is greyed out. Any logic to this?
- Pragati11Super User
Hi Anonymous ,
Not sure if this is the right thread for you to post your question as i is not related to the question of the original thread.
Can you please create a new thread for your question? In this way you are not taking over other person's thread.