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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
_Regina
Helper I
Helper I

Need help with power query

Hi All,

@amitchandak 

I have a date column in one of my source. The source used is a smartsheet which is filled manually. The date column in this smartsheet is populated in 2 different formats 1/10/2022 which is read correctly by Power BI as January 10,2022 but if the value is 05-04-22 it is read by Power BI as April 22,2005 whereas it should be May 4 ,2022. 

 

I have described below what I am thinking to do, but would appreciate any ideas to format the date field consistently.

 

In order to format the date correctly, I was thinking of using power query and add columns to extract first 2 characters, text between delimiters and the last characters. How can I write an if statement in power query which does something like this :

If delimiter is '-' then extract between 1st and 2nd delimiter else if delimiter is '/' then extract between 1st and 2nd delimiter.

 

Table.AddColumn(#"Inserted First Characters", "Text Between Delimiters", each if Text.Contains([Date], "-") then each Text.BetweenDelimiters([Date], "-", "-"), type text) else if Text.Contains([Date], "/") each Text.BetweenDelimiters([Date], "/", "/"), type text)

1 ACCEPTED SOLUTION
wdx223_Daniel
Community Champion
Community Champion

try the second parameter

wdx223_Daniel_0-1659572877500.png

 

View solution in original post

2 REPLIES 2
wdx223_Daniel
Community Champion
Community Champion

try the second parameter

wdx223_Daniel_0-1659572877500.png

 

Thank you so much !!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors