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
Anonymous
Not applicable

A year later

I  want to calculate when a year has passed. Tried this:

AYearLater = Date(Year([Start date]) + 1,
                              Month([Start date]),
                              Day([Start date]) )

But DAX says that I have an argument of the wrong data type or too large or too small. Presumably this is (Year([Start date]) + 1) as replacing that with a number or with Year([Start date]) is fine.

So I tried

AYearLater =
Var YearOn = Year([Start date]) + 1
Return
Date(YearOn, Month([Start date]), Day([Start date]))
And that's no better.
AYearOn = Year(Start date) + 1 returns a perfectly ordinary integer.
I tried (Int(Year([Start date]) + 1) : no good.
 
I realise I could use Edate([Start date], 12) but I don't see why DAX objects to my original attempt.
1 ACCEPTED SOLUTION

Hi @Anonymous,

This may cause by date table include some invalid date value that can't be process with date function. You can try to add a ISERROR function to check these values before calculations:

DateTest =
IF (
    ISERROR ( DATEVALUE ( 'Date'[Date] & "" ) ),
    BLANK (),
    DATE ( YEAR ( 'Date'[Date] ) + 1, MONTH ( 'Date'[Date] ), DAY ( 'Date'[Date] ) )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

6 REPLIES 6
ppm1
Solution Sage
Solution Sage

I tried your syntax (below) in a calculated column and it worked fine. Just confirming you are talking about a calculated column, and that [Start date] is not a measure.

 

DateTest = DATE(YEAR('Date'[Date])+1, Month('Date'[Date]), DAY('Date'[Date]))
 
Pat
 
Microsoft Employee

Hi @Anonymous,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

I'm afraid not. I thought I'd answered the question ppm1 asked me. It seems the code works for ppm1 but not for me. I have no idea why this should be, or what else to tell you.

 

PBI could be a bit more helpful about its DAX complaints. "an argument of the wrong data type or too large or too small" doesn't tell me where to look. Which argument? The interpreter must know. However changing the Year argument to remove any calculations removed the error so that tells me where to look. That doesn't explain why [Field] is an acceptable value but [Field]+1 is not.

Hi @Anonymous,

This may cause by date table include some invalid date value that can't be process with date function. You can try to add a ISERROR function to check these values before calculations:

DateTest =
IF (
    ISERROR ( DATEVALUE ( 'Date'[Date] & "" ) ),
    BLANK (),
    DATE ( YEAR ( 'Date'[Date] ) + 1, MONTH ( 'Date'[Date] ), DAY ( 'Date'[Date] ) )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

That is helpful, thank you. There was a blank in the Start date column.

Anonymous
Not applicable

Yes, a calculated column

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.