Forum Discussion
Line graph with two colors based on a paramether value????
Hey there!
You could try creating a measure for conditional coloring. Like this:
Line_Color =
VAR Threshold = SELECTEDVALUE(ParameterTable[ParameterValue])
VAR CurrentValue = SELECTEDVALUE(YourData[WeeklyValue])
RETURN
IF(CurrentValue >= Threshold, "Green", "Red")
-------Replace ParameterTable[ParameterValue] with the actual parameter table column.
-------Replace YourData[WeeklyValue] with your dataset's weekly values.
And then apply conditional formatting in the line chart. :
- Select the line graph.
- Click on the Format pane (paint roller icon).
- Go to the Data Colors section.
-Click on the fx (conditional formatting) next to the line color.
-Choose "Based on field", then select the Line_Color measure.
With this, when the weekly value is above the parameter → Line turns green.
When the weekly value is below the parameter → Line turns red.
Hope this helps!
😁😁
Set "Green" to one color (e.g., Green) and "Red" to another (e.g., Red).
- Krlos54111 year agoFrequent Visitor
Thansk for the guide.
I think I got all correct. But I don't have the fx button next to the line color option
- kushanNa1 year agoSuper User
Hi ,
I'm not sure you can achive this using one line , you will need two lines for this one for green and the other for red
steps to get the above result
1. create two mesure for green and red
RedLineMeasure = VAR Threshold = SELECTEDVALUE(ParameterTable[ParameterValue]) VAR AvgLeadTime = AVERAGEX( YourData, DATEDIFF(YourData[LeadTime_Date], YourData[Date], DAY) ) RETURN IF(AvgLeadTime <= Threshold, AvgLeadTime, BLANK()) GreenLineMeasure = VAR Threshold = SELECTEDVALUE(ParameterTable[ParameterValue]) VAR AvgLeadTime = AVERAGEX( YourData, DATEDIFF(YourData[LeadTime_Date], YourData[Date], DAY) ) RETURN IF(AvgLeadTime >= Threshold, AvgLeadTime, BLANK())2. add the following values to line chart
3. and color code each lines , i have shown in here green as an example