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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Pedro_Silveira
Regular Visitor

Return specific value from measure

I'm having a bit of an issue with my dashboard

 

Currently trying to implant a new dashboard in my company (they only used Excel) and one thing my boss requires is the mobile average of a certain period of time. But instead of having different values for different dates, he prefers to see the mobile average of the last date as a straight line over the dashboard.

 

Easy solution was to use the built-in function on column graphs, but also need a bit more data on the board, making the function unavailable.

 

Already got mobile average calculated in a measure (MobileAVG), that's my main issue on returning expected value.

 

Pedro_Silveira_0-1697486576668.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Pedro_Silveira ,

Please try to use the DAX language to create a measure that calculates the mobile average of the last date in your data. You can then add this measure to your line chart or any other visual that supports measures. For example, if you have a table called Sales with columns Date and Amount, you can create a measure like this:

Mobile Average =
VAR _LastDate =
    MAX ( Sales[Date] )
VAR _Period = 30 // change this to your desired period 
VAR _MobileAverage =
    AVERAGEX (
        FILTER ( Sales, Sales[Date] >= _LastDate - _Period && Sales[Date] <= _LastDate ),
        Sales[Amount]
    )
RETURN
    _MobileAverage

This formula uses the MAX function to get the last date in the data, the AVERAGEX function to calculate the average amount over a specified period, and the FILTER function to filter the data by date range. You can then add this measure to your line chart and it will show a straight line with the mobile average value.

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Pedro_Silveira ,

Please try to use the DAX language to create a measure that calculates the mobile average of the last date in your data. You can then add this measure to your line chart or any other visual that supports measures. For example, if you have a table called Sales with columns Date and Amount, you can create a measure like this:

Mobile Average =
VAR _LastDate =
    MAX ( Sales[Date] )
VAR _Period = 30 // change this to your desired period 
VAR _MobileAverage =
    AVERAGEX (
        FILTER ( Sales, Sales[Date] >= _LastDate - _Period && Sales[Date] <= _LastDate ),
        Sales[Amount]
    )
RETURN
    _MobileAverage

This formula uses the MAX function to get the last date in the data, the AVERAGEX function to calculate the average amount over a specified period, and the FILTER function to filter the data by date range. You can then add this measure to your line chart and it will show a straight line with the mobile average value.

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

amitchandak
Super User
Super User

@Pedro_Silveira , Try a measure like

Avg Line =
var _max =maxx(allselected(Date), Date[Date])
return

Calculate(AverageX(values(Table[Mobile]), Calculate(Sum(Table[Value]))), filter(Date, Date[Date] = _max))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors