Forum Discussion

Krlos5411's avatar
Krlos5411
Frequent Visitor
1 year ago

Line graph with two colors based on a paramether value????

Hello experts,

 

Quick question if anyone knows that is possible.

 

I have a line graph with weekly values, those values depends of the data that is updated weekly.

And I have a paramether that can be manually modified by the user. But this value is used only to have a minimun a acceptable value.

 

There's a way where I can change the color of the weekly values that came from databricks, base on the value of the paramether?

 

Above green and below red, like this:

 

5 Replies

  • freginier's avatar
    freginier
    Solution Sage

    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).

    • Krlos5411's avatar
      Krlos5411
      Frequent 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

       

       

      • kushanNa's avatar
        kushanNa
        Super 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 

         

         

  • v-kathullac's avatar
    v-kathullac
    Community Support

    Hi Krlos5411 ,

    we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.

    If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.


    Regards,

    Chaithanya.

  • v-kathullac's avatar
    v-kathullac
    Community Support

    Hi @Krlos5411 ,

    we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.

    If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.


    Regards,

    Chaithanya.