Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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:
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.