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

DATEADD based on max date

Hi folks,

 

I need to calculate the past 12 months based on the max date. Please, any idea?

 

I try dateadd and it is not working.

 

claraigg_0-1712845811118.png

MAX_sent_payment = max('All Expenses'[Sent for Payment Date])
 
So in my example, if the max date= March-2024, I would like March-2023
Thank you,
 
Clara

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Dateadd is a table function and cannot be directly useful for metric values. You can see the results returned by the dateadd function by creating a calculated table.

vkongfanfmsft_0-1712901520201.png

vkongfanfmsft_1-1712901595928.png

You can try below formula:

M_ = 
CALCULATE (
    SUM ( 'Table 2'[value] ),
    DATESBETWEEN (
        'Table 2'[Date],
        MAX ( 'Table 2'[Date] ) - 365,
        MAX ( 'Table 2'[Date] )
    )
)

vkongfanfmsft_2-1712903930603.png

 

Best Regards,
Adamk Kong

 

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

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

Dateadd is a table function and cannot be directly useful for metric values. You can see the results returned by the dateadd function by creating a calculated table.

vkongfanfmsft_0-1712901520201.png

vkongfanfmsft_1-1712901595928.png

You can try below formula:

M_ = 
CALCULATE (
    SUM ( 'Table 2'[value] ),
    DATESBETWEEN (
        'Table 2'[Date],
        MAX ( 'Table 2'[Date] ) - 365,
        MAX ( 'Table 2'[Date] )
    )
)

vkongfanfmsft_2-1712903930603.png

 

Best Regards,
Adamk Kong

 

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

 

Greg_Deckler
Community Champion
Community Champion

@Anonymous 12_months = EOMONTH( [Max_sent_payment], -13) + 1

 

You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
johnbasha33
Super User
Super User

@Anonymous try the below
Past_12_Months_Start_Date = DATEADD(MAX('All Expenses'[Sent for Payment Date]), -12, MONTH)

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

Anonymous
Not applicable

Yeah, that was my first approach. However, it did not work.

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.