Forum Discussion

ajazz's avatar
ajazz
Frequent Visitor
5 years ago
Solved

Dynamic Reference Line on line chart

Hi there,

I was wondering if it is possible to add a dynamic reference line to a line chart.

In my line chart I have some filtered products by a slicer. On the y-axis i have price and x-axis i have date.

My objective is to show a dynamic reference line, where it takes the cheapest filtered product and adds the value 50 to the price. It should be dynamic, so that it takes the cheapest product from that particular date and not the general cheapest product.

I would like to show the dynamic reference line on the line chart.

I have tried to draw how it should be (the red line is the dynamic reference line that im seeking):

 


Any help would be very appreciated.

Thanks in advance!

  • Hi  ajazz ,

     

    Sorry for the late reply.

    Create 2 measures as below:

    Average =
    AVERAGEX (
        FILTER (
            ALLSELECTED ( MedicinPriserUnpivot ),
            'MedicinPriserUnpivot'[Varenummer] = MAX ( MedicinPriserUnpivot[Varenummer] )
                && 'MedicinPriserUnpivot'[Dato] = MAX ( 'MedicinPriserUnpivot'[Dato] )
        ),
        'MedicinPriserUnpivot'[Pris]
    )
    
    Measure2 =
    VAR _tab =
        CALCULATETABLE (
            VALUES ( 'Vareoversigt'[Varenummer] ),
            FILTER (
                ALL ( Vareoversigt ),
                'Vareoversigt'[Substitutionsgruppe]
                    IN FILTERS ( Vareoversigt[Substitutionsgruppe] )
            )
        )
    RETURN
        CALCULATE (
            MINX ( ALLSELECTED ( MedicinPriserUnpivot ), [Average] ),
            FILTER (
                ALLSELECTED ( 'MedicinPriserUnpivot' ),
                'MedicinPriserUnpivot'[Dato] = MAX ( 'MedicinPriserUnpivot'[Dato] )
                    && 'MedicinPriserUnpivot'[Varenummer] IN _tab
            )
        ) + 50
    

    And you will see:

    For the related .pbix file,pls see attached.

     

    Best Regards,
    Kelly

    Did I answer your question? Mark my reply as a solution!

16 Replies

  • v-kelly-msft's avatar
    v-kelly-msft
    Community Support

    Hi ajazz ,

     

    Could you pls provide some sample data with expected output for test?

    Remember to remove the confidential information.

     

    Best Regards,
    Kelly

    Did I answer your question? Mark my reply as a solution!

    • ajazz's avatar
      ajazz
      Frequent Visitor

      Hi again,

      It needs to be average price per ProductNumber.
      Then a slicer to select 3-4 productnumbers.

      Of the "filtered" view, the reference line needs to take the ProductNumber with the lowest price and add +50 to it.

       

      Does that make sense?

      • v-kelly-msft's avatar
        v-kelly-msft
        Community Support

        Hi ajazz ,

         

        Do you mean that the reference line is combined by loweast price of each month +50?

         

        Best Regards,
        Kelly

        Did I answer your question? Mark my reply as a solution!