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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

Top Solution Authors