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
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]))

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]))

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.