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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

YTD average of a measure

Howdy! I'd like to ask how to calculate a YTD average of a measure? E.g. below a line showing 80%, 72.5%, 68.3%, etc. On top of this, the underlying date strucutre is on a per day basis. I'd like the YTD average to be on sum of values in a month.

Capture.JPG

Any help would be much appreciated!

 

Example pbi: https://tmpfiles.org/download/102006/QuestionExample.pbix

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Please try this measure expression.  Note I first needed to add a Month column to your required table with

Month = MONTH('Required Line'[Date])
 
YTD Avg =
VAR maxdate =
    MAX ( 'Required Line'[Date] )
RETURN
    CALCULATE (
        AVERAGEX (
            VALUES ( 'Required Line'[Month] ),
            [Percentage uptime]
        ),
        ALL ( 'Required Line'[Date] ),
        'Required Line'[Date] <= maxdate
    )
 
Regards,
Pat




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

6 REPLIES 6
mahoneypat
Microsoft Employee
Microsoft Employee

Please try this measure expression.  Note I first needed to add a Month column to your required table with

Month = MONTH('Required Line'[Date])
 
YTD Avg =
VAR maxdate =
    MAX ( 'Required Line'[Date] )
RETURN
    CALCULATE (
        AVERAGEX (
            VALUES ( 'Required Line'[Month] ),
            [Percentage uptime]
        ),
        ALL ( 'Required Line'[Date] ),
        'Required Line'[Date] <= maxdate
    )
 
Regards,
Pat




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Awesome, that worked like a charm, thank you!!

Anonymous
Not applicable

Hi  @Anonymous ,

According to your description, I created some data October 1, 2019 to December 5, 2020 to show

YTD03.png

1. Open the line chart, place the date column in axis and the amount in value

YTD04.jpg

2. Select analytics, find average line 1, and select Add. After that, a horizontal line will appear, which is the year to date average

YTD01.jpg

3. Result.

YTD02.jpg

You can downloaded PBIX file from here.

 

If my answer is not what you need, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Best Regards,

Liu Yang

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

Anonymous
Not applicable

@Anonymous that is not quite what I'm looking for as I'd like the YTD average to change per month. I have attached an example pbi in my original question. Is there a recomendation as to the best way to share such files?

amitchandak
Super User
Super User

@Anonymous , Avg with TI and date table

example

YTD Sales = CALCULATE(Average(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))/ CALCULATE(distinctcount(Date[Month Year]),DATESYTD('Date'[Date],"12/31"), not(isblank(SUM(Sales[Sales Amount]))))

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
Anonymous
Not applicable

@amitchandak I don't think this works if the item is a measure. The "Average" function only works with columns.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.