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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
franorio
Helper III
Helper III

Time intelligence add months to a given date

Hello everybody,  

got a question, is it possible to add/sum time to a given date?

Got my report working with a Dim Calendar Table. Long story short, 

I need always to have added 3 months to each date, for example. 3/23/2016 should be 6/23/2016.. for 11/26/2016 should be 2/26/2017.. 

 

is there a  way to have this done? keeping the final colum with a date format

 

Regards!

 

1 ACCEPTED SOLUTION
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @franorio,

Please try the function Dateadd function, here is the link: https://msdn.microsoft.com/en-us/library/ee634905.aspx.

You can also use the formula to create a calculated column.

Column = DATE(YEAR('Test1'[Date]),MONTH('Test1'[Date])+3,DAY('Test1'[Date]))


I use my sample data and get the expected result, please see the following screenhot. Then you can use the new date to create visual.

1.PNG

Thanks,
Angelia

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

@franorio 
I am finding that DAX may not be the solution for this one.  In my case, I used Power Query to edit the table (adding 3 months after the date) before bringing it into the model.

 

Fore example, in power query you can create a custom column stating:

 

Add 3 months to a given fact table date column

=
Date.AddMonths( [Snapshot_Date],3)

 

I have found using DAX formulas may pose ambiguity when adding months to dates where the 'day number' is > 28.

for example:

8/31/2019 + 1 month = 9/31/2019 (which does dot exist!) 

Dax example using Dates = 
    DATE(
        YEAR([Snapshot Date]),
            MONTH([Snapshot Date])+1,
                DAY([Snapshot Date])
    )

 

For this reason, the Power Query route may be a better solution for you depending on your situation.

 

 

 

 

 

v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @franorio,

Please try the function Dateadd function, here is the link: https://msdn.microsoft.com/en-us/library/ee634905.aspx.

You can also use the formula to create a calculated column.

Column = DATE(YEAR('Test1'[Date]),MONTH('Test1'[Date])+3,DAY('Test1'[Date]))


I use my sample data and get the expected result, please see the following screenhot. Then you can use the new date to create visual.

1.PNG

Thanks,
Angelia

It is unfortunate that this solution comes up as the first option when searching for this topic.  If you had included an example with a source date in November you'd notice that a date with month number 14 can't exist. 

dedelman_clng
Community Champion
Community Champion

DATEADD(<dates>,<number_of_intervals>,<interval>) 

e.g.

DATEADD(DimCalendarTable[Date], 3, MONTH)

 

Be careful though - dealing with months (and weeks) can get tricky like when you need to add 3 months to Nov 30 (which would give Feb 30 which doesn't exist). 

 

Also, this warning from the DAX Function Reference  - "The result table includes only dates that exist in the dates column."  So if your calendar table only goes through TODAY() for example, you may not get the results you are looking for.

 

Hope this helps

David

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.