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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

How to convert and calculate text to date while ignoring incorrect values?

Hello all,

 

i have text in column in format YYYY-MM. I'd like to convert text to date, but I'd like to add 2 months to the selection and also ignore incorrect values. See table below. Any idea how to do it?

 

curent formatshould result in
2016-01March 2016
2016-02April 2016
2016-03May 2016
2016-10December 2016
2016-11January 2017
2016-13ignore
2016-99ignore
2016-00ignore

 

I tried to do some workarounds in DAX and Calculated Columns with splitting columns and such, but didn't get results I'd like to see. 😞

 

Many thanks a in advance.

 

Best regards

MV

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

This would be far better to do before DAX (in Power Query / "M"), but... since i played with it... 

 

Plus2Month = var RawDate = IFERROR(DATEVALUE(Table1[RawDate] & "-01"), datevalue("1-1-1900")) return if (YEAR(RawDate) = 1900, BLANK(), Date(Year(RawDate), Month(RawDate)+2, 1))

 

View solution in original post

Anonymous
Not applicable

Via M:

#"Inserted Parsed Date" = Table.AddColumn(#"Renamed Columns", "ParseDate", each Date.From(DateTimeZone.From([RawDate])), type date),
#"Plus 2 Months" = Table.AddColumn(#"Inserted Parsed Date", "Plus 2 Months", each Date.AddMonths([ParseDate], 2), type date)

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

This would be far better to do before DAX (in Power Query / "M"), but... since i played with it... 

 

Plus2Month = var RawDate = IFERROR(DATEVALUE(Table1[RawDate] & "-01"), datevalue("1-1-1900")) return if (YEAR(RawDate) = 1900, BLANK(), Date(Year(RawDate), Month(RawDate)+2, 1))

 

Anonymous
Not applicable

Via M:

#"Inserted Parsed Date" = Table.AddColumn(#"Renamed Columns", "ParseDate", each Date.From(DateTimeZone.From([RawDate])), type date),
#"Plus 2 Months" = Table.AddColumn(#"Inserted Parsed Date", "Plus 2 Months", each Date.AddMonths([ParseDate], 2), type date)

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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