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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MarkMellink
Frequent Visitor

DateAdd for measures

Hi,

 

I have a measure, which is a DateTime. I'm trying to subtract Years/Months/Days from this measure. But can't seem to find an easy way to do this.

 

Basically, I'm looking for a DateAdd function, but that accepts a single date instead of a column of date.

 

Example:

 

Measure: [FirstDate] = MIN(Table[Date])

FirstDate20DaysAdded = DateAdd([Firstdate],20,Days)

3 REPLIES 3
Paz2019
Regular Visitor

Hi! Could you resolve it? I want to do the same (Dateadd for a measure and not to a column)

I recommend that you put the exercise you want to find to be able to understand the dateadd what it does is Returns a table that contains a column of dates, shifted either forward or backward in time by the specified number of intervals from the dates in the current context.

Alright. What I eventually want to do is get the difference between that measure, and the current day. But in a text format, for example:

* 2 year(s), 3 month(s), 22 day(s).

* 3 month(s), 22 day(s).

* 22 day(s)

 

I've broken this up into several measures:

 

[FirstDate] = MIN(Table[Date])

[YearValue] = DATEDIFF([FirstDate],TODAY(),YEAR)

[YearValueText] = IF([YearValue] >= 1, CONCAT([YearValue]," year(s)"), "")

[MonthValue] = DATEDIFF(DATEADD([FirstDate],[YearValue],YEAR),TODAY(),MONTH)

This is where I need that DATEADD for a measure.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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