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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. 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]))

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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors