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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
rijnhardtk
New Member

Year To Date based on Maximum Date in Column

Hi 

 

I need to calculate the Year To Date to the maximum value of a column. 

 

Ie. If the latest date in the dataset is 2 March, I need it to calculate YTD to 2 March, not 23 March (today's date)

 

Here is my attempt at a query. 

 

Pt Basket YTD = 
CALCULATE(
    CALCULATE( // total revenue
        AVERAGE('Calendar'[Total Revenue]), 
        FILTER('Calendar', 'Calendar'[Total Revenue] > 0)
    )
    / //div
    CALCULATE( // platinum production
        AVERAGE('Calendar'[Platinum - Production]), 
        FILTER('Calendar', 'Calendar'[Platinum - Production] > 0)
    ), // start of filter
    YEAR('Calendar'[Date]) // date of data
    =
    CALCULATE( // find the maximum date in data
        MAX('Calendar'[Date].[Year]),
        ALL('Calendar')
    )
)

Assistance is appreciated!

 

BONUS QUESTION

 

How do I translate this to a month to date calculation? 

1 REPLY 1
Phil_Seamark
Microsoft Employee
Microsoft Employee

HI @rijnhardtk

 

That doesn't look like a Year to Date calculation (Cumulative over a year)

 

I recommend having a look at the TOTALYTD function and you could build your measure along these lines

 

Pt Basket YTD = 
VAR ReturnVal = 
    TOTALYTD(
        DIVIDE(
            AVERAGE('Calendar'[Total Revenue]) , 
            AVERAGE('Calendar'[Platinum - Production])
            ) , 
            'Calendar'[Date]
            )
VAR MaxDateInTable = MAX('Calendar'[Date])

RETURN 
    IF(
        MAX('Calendar'[Date])<=MaxDateInTable,
        ReturnVal
        )

Then if you use this measure in a visual with the 'Calendar'[Date] field on your Axis, you might be close.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors