March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
I want to filter out all the values that do not look like dates in a column in Power Query. Here is the sample data.
N/A |
6/1/2019 |
12/4/2018 |
7/1/2020 |
TBC |
10/26/2021 |
Nov_18 |
In the above example, I want to filter out N/A, TBC, and NOV_18. is there an automated way to do that in power query?
Regards,
Anuj
Hi @itsmeanuj
You can put the following code to advanced editor in power query
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8tN3VIrViVYy0zfUNzIwtARzDI30TUA8CzDPHCxlZADmhDg5Q5QY6BuZgYQNwVy//LJ4kPJYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each try Value.Is(Date.FromText([Value]),type date) otherwise null),
#"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] = true)),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Custom"})
in
#"Removed Columns"
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello @itsmeanuj ,
you could remove it from power query by clicking the drop down arrow for the filtering and uncheck it. thus it won't show.
Proud to be a Super User! | |
You could just change the data type to Date, then remove errors.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8tN3VIrViVYy0zfUNzIwtARzDI30TUA8CzDPHCxlZADmhDg5Q5QY6BuZgYQNwVy//LJ4kPJYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type date}}),
#"Removed Errors" = Table.RemoveRowsWithErrors(#"Changed Type", {"Column1"})
in
#"Removed Errors"
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
89 | |
84 | |
70 | |
51 |
User | Count |
---|---|
206 | |
143 | |
97 | |
79 | |
68 |