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
I'm trying to sanitize some records with bad dates that were originally stored as text by copying them into a new field. For the records that are stored as alpha characters, this line is correctly passing a null to the new date column :
Solved! Go to Solution.
You'll want something along the lines of this :
if Number.FromText(Text.AfterDelimiter([cr09e_column11],"/",1)) < 1953 then null else [cr09e_column11]
Null is a special case - try Googling 'power query null'.
You'll want something like this:
if [cr09e_column15] = null then null else if Number.FromText([cr09e_column15]) < 1753 then null else try Date.FromText(Text.Combine({[cr09e_column14],[cr09e_column13],[cr09e_column15]},"/")) otherwise null
Can you tell me why "try Number.FromText(194*) otherwise null" fails? If that value it come across isn't a number, because of the astericks, why is the code failing? Is "194*" a number to power query?
Hi @dsjaff, what about this?
Result
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTSNzbUNzIwMlaK1YFxDU0twTxkIUtTAzDXwFDfAMwFaogFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
ReplacedValue = Table.ReplaceValue(Source,"",null,Replacer.ReplaceValue,{"Date"}),
AddedCustom = Table.AddColumn(ReplacedValue, "Custom", each try if Date.From([Date], "en-US") < #date(1953,1,1) then null else Date.From([Date], "en-US") otherwise null, type date)
in
AddedCustom
This has way too much going on for me to understand. I've only used power query a handful of times.
Of cource if you do not use PQ often, it is not easy to understand some queries. Were you able to use my query? If no check note below my posts or just use part of code form AddedCustom step and edit with your needs (column name). Add it as custom column.
try if Date.From([Date], "en-US") < #date(1953,1,1) then null else Date.From([Date], "en-US") otherwise null
Null is a special case - try Googling 'power query null'.
You'll want something like this:
if [cr09e_column15] = null then null else if Number.FromText([cr09e_column15]) < 1753 then null else try Date.FromText(Text.Combine({[cr09e_column14],[cr09e_column13],[cr09e_column15]},"/")) otherwise null
You'll want something along the lines of this :
if Number.FromText(Text.AfterDelimiter([cr09e_column11],"/",1)) < 1953 then null else [cr09e_column11]
I got it to work as this:
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.