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