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 ...
  • v-kelly-msft's avatar
    v-kelly-msft
    4 years ago

    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!