Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
kay87
Frequent Visitor

Reference Line Question

Hi All

 

I am an advanced Qlik user and looking to find a way to add a reference line to a trend chart in Power BI.

 

I have a calculated measure ie KPI_5_BaseLineMean which returns one value depending on date selections. I would like to add this measure as a reference line to the line chart. Please see the example screenshots below.

 

 

1.PNG2.PNG

 

Regards

Kay

2 ACCEPTED SOLUTIONS
MFelix
Super User
Super User

Hi @kay87,

 

I have made a mockup of a file using only dates + value and calculating the moving average:

  • Create a date table
  • Make a non-active relationship between both table based on date
  • Create the following measure:
  • BASE_LINE = 
    CALCULATE (
        AVERAGEX (
            SUMMARIZE (
                ALL ( 'Fact Table'[Date]; 'Fact Table'[Values] );
                'Fact Table'[Date];
                "AVERAGE VALUES"; AVERAGE ( 'Fact Table'[Values] )
            );
            [AVERAGE VALUES]
        );
        'Fact Table'[Date] = VALUES ( 'Fact Table'[Date] );
        USERELATIONSHIP ( DimDate[Date]; 'Fact Table'[Date] )
    )
    Be aware that I'm using AVERAGEX but based on your context you may have to use another type of aggregator.
  • Create a slicer with the Date table date
  • Add the measure to your line chart along side with the values.

As you can see the average is moving with the changes of the slicer.

 

moving_average.gif

 

Not sure if this is waht you need.

 

Regards,

Mfelix

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

kay87
Frequent Visitor

Thank you soo very much for this MFelix. This is very close to what I want to do. My average formula is very different but this is massively helpful and point sme in a direction. 

 

Is there a chance you could share the bix file for my reference?

 

Regards

Kay

View solution in original post

4 REPLIES 4
MFelix
Super User
Super User

Hi @kay87,

 

I have made a mockup of a file using only dates + value and calculating the moving average:

  • Create a date table
  • Make a non-active relationship between both table based on date
  • Create the following measure:
  • BASE_LINE = 
    CALCULATE (
        AVERAGEX (
            SUMMARIZE (
                ALL ( 'Fact Table'[Date]; 'Fact Table'[Values] );
                'Fact Table'[Date];
                "AVERAGE VALUES"; AVERAGE ( 'Fact Table'[Values] )
            );
            [AVERAGE VALUES]
        );
        'Fact Table'[Date] = VALUES ( 'Fact Table'[Date] );
        USERELATIONSHIP ( DimDate[Date]; 'Fact Table'[Date] )
    )
    Be aware that I'm using AVERAGEX but based on your context you may have to use another type of aggregator.
  • Create a slicer with the Date table date
  • Add the measure to your line chart along side with the values.

As you can see the average is moving with the changes of the slicer.

 

moving_average.gif

 

Not sure if this is waht you need.

 

Regards,

Mfelix

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



kay87
Frequent Visitor

Thank you soo very much for this MFelix. This is very close to what I want to do. My average formula is very different but this is massively helpful and point sme in a direction. 

 

Is there a chance you could share the bix file for my reference?

 

Regards

Kay

Hi @kay87,

 

See attach the PBIX file.

 

Be aware it's a we transfer link so will only last 7 days.

 

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Greg_Deckler
Super User
Super User

Didn't get the screen shots. You could potentially do this via something like a clustered column and line chart visual.

 

OK, now I see the screen shots. Weird. Well, currently you cannot use columns or measures in Analytics pane constant lines to the best of my knowledge.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.