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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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