cancel
Showing results for
Did you mean:

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

Helper II

## 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.

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
Community Support

Hi @claraigg ,

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.

You can try below formula:

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

Best Regards,

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

4 REPLIES 4
Community Support

Hi @claraigg ,

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.

You can try below formula:

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

Best Regards,

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

Super User

@claraigg 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-TIT...

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Solution Sage

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

Helper II

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

Announcements

#### Fabric certifications survey

Certification feedback opportunity for the community.

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors