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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
andrea_chiappo
Helper III
Helper III

add one year to date column

This should be very easy, yet it doens't work

 

I tried both creating a new column and a new measure to get dates one year 

ahead with respect to the date column you see in the attachment.  

As you can see, the createdDate is in Date format.  

 

I tried the first logical thing:  

LastDate = DATEADD('TableName'[createdDate], 1, YEAR)
 
But I get the error (that's starting to become very annoying) that  
a table of multiple values was supplied where a single value was expected
 
I tried using DISTINCT() and even the function which usually prevents DAX from complainig, 
FIRSTNONBLANK, even if I'm absolutely unsure why, but time time neither of them works.
 

Capture_LI (2).jpg

 

Why doesn't it work?

Why can't it be easy to evaluate things with DAX?

Why most functions do not operate as the refernce says?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@andrea_chiappo 

As a new column is should have worked. Check are you creating a measure or column

You can also try a new measure like

New column = Date(year('TableName'[createdDate])+1,month('TableName'[createdDate]),day('TableName'[createdDate]))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

3 REPLIES 3
V-lianl-msft
Community Support
Community Support

Hi @andrea_chiappo ,

 

If the dates in the current context do not form a contiguous interval, the function returns an error. See this thread for a more comprehensive explanation.

You can try the formula mentioned in @amitchandak .

You can also try this:

LastDate = DATEADD('TableName'[createdDate].[DATE], 1, YEAR)

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Nope, it doesn't allow this operation, saying that:  

Column reference to 'createdDate' in table 'DimCustomers'cannot be used with a variation 'Date' because it does not have any  

 

 'createdDate' looks like this

Capture.PNG

amitchandak
Super User
Super User

@andrea_chiappo 

As a new column is should have worked. Check are you creating a measure or column

You can also try a new measure like

New column = Date(year('TableName'[createdDate])+1,month('TableName'[createdDate]),day('TableName'[createdDate]))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

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