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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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