Forum Discussion
Table.ReplaceValue list not replacing null data consistently
- 3 years ago
In this example, the nulls are not empty strings or actual blanks, they are text "null". However, replacing "null" with null did recreate your issue. Here's a simplified version of what you provided:
let Source = Table.FromRows( Json.Document( Binary.Decompress( Binary.FromText( "i45WckwpSy0qySzOzEtX0lEqTi5IAVJ5pTk5SrE60UoBiUUlealF+s75ecWlOSWJeSUK7qlAgcSSVJC6MBMF54zU5GyFoNTkzILM1LwSZM14jI4FAA==", BinaryEncoding.Base64 ), Compression.Deflate ) ), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [LeadSource = _t, Lead_Source_Detail__c = _t, #"Person Source" = _t] ), #"Replaced Value" = Table.ReplaceValue( Source, "null", null, Replacer.ReplaceValue, Table.ColumnNames(Source) ), #"Person Source Replace null" = Table.ReplaceValue( #"Replaced Value", null, each if [Person Source] = null and List.Contains({"Advertising"}, [LeadSource]) then "Digital Advertising" else if [Person Source] = null and Text.Contains([Lead_Source_Detail__c] = "conference") then "Event" else if [Person Source] = null then "none" else [Person Source], Replacer.ReplaceValue, {"Person Source"} ) in #"Person Source Replace null"The problem is with
Text.Contains([Lead_Source_Detail__c] = "conference")On its own, this throws the error "Expression.Error: 1 arguments were passed to a function which expects between 2 and 3".
I haven't dug into why just eats the error when included inside else if instead of returning an error for that row, but all that's needed to resolve it is to replace "=" with ",".
Text.Contains([Lead_Source_Detail__c], "conference")
Yes, the data is null but good call out. Below is a screen shot of the column where nulls don't get transformed after applying the step. They should get converted to the text value "none" but remain as null. Full syntax is above in the original post.
I can't reproduce this behavior. What's the simplest case where you can?
Here's what I tried:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUorViVZyySxKTS5RCE9NAnMxxGIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Person Source" = _t]),
#"Replaced Value" = Table.ReplaceValue(Source,"",null,Replacer.ReplaceValue,{"Person Source"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value", null, each if [Person Source] = null then "none" else [Person Source], Replacer.ReplaceValue, {"Person Source"})
in
#"Replaced Value1"- jfbonterra3 years agoFrequent Visitor
So you eseentially transformed the data from "" to null and then null to conditionally "none"?
Here is pared down syntax where still getting the null data:
Table.ReplaceValue(#"Rename Columns",null,each if [Person Source] is nulland [Lead_Source_Subcategory__c] = "Capterra"then "Review Sites"else if [Person Source] is nulland [LeadSource] = "Web Referral"then "Web Referral"else if [Person Source] = null then "none"else [Person Source],Replacer.ReplaceValue,{"Person Source"} )Possibly unrelated but I've also noticed my data type gets converted from text to untyped after applying this replace text step. Not sure why.
- AlexisOlson3 years ago
Super User
I created a query (using the Enter Data button) that you can copy and paste into the Advanced Editor of a new blank query. It interprets empty cells as empty strings instead of nulls, which is why I did the first replacement before attempting a simplified version of what you're trying to do.
I can't reproduce your problem from what you've shared (my attempt replaced the nulls just fine). Can you share an entire self-contained query like I did that has the same issue?
- jfbonterra3 years agoFrequent Visitor
I see. How do I create a self-contained query? Does it need to be through a .pbix file? The dataset I'm working in is in an online data flow.