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

Subtract or Add #s to a date field in M Query

I would like to be able to subtract or add a # of days from a date field in the query editor.   In one column I have number of days (5,300, 60) and in another column i have dates 01/01/2018.  Is there a custom column function that will subtract or add?

 

 

Example......   01/01/2018 + [Date Field] (5) = 01/06/2018 

Thanks!

 

 

1 ACCEPTED SOLUTION

@Anonymous,

 

Change the data type if necessary.

Date.AddDays(Date.From([Start Date]), Number.From([Promote_or_Defer__c]))
Community Support Team _ Sam Zha
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
MarcelBeug
Community Champion
Community Champion

Yes: Date.AddDays.

Specializing in Power Query Formula Language (M)
Anonymous
Not applicable

When I use the formula for dateadd it doesn't do the calculation.

 

Date.AddDays([Start Date], [Promote_or_Defer__c])

@Anonymous,

 

Change the data type if necessary.

Date.AddDays(Date.From([Start Date]), Number.From([Promote_or_Defer__c]))
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

let
    Source = #table(type table[Start Date = date,Promote_or_Defer__c = Int64.Type], {{#date(2017,12,18),-10},{#date(2017,12,18),10}}),
    #"Added Custom" = Table.AddColumn(Source, "Resulting Data", each Date.AddDays([Start Date],[Promote_or_Defer__c]), type date)
in
    #"Added Custom"
Specializing in Power Query Formula Language (M)

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.