Forum Discussion
Need help with Data Cleansing
- 4 years ago
For overwriting the values, DAX can't be used. For this purpose, you will need to use PQ.
See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcq0oSS3KU9JRMgJic2NDfXMDQ0M9IAZyDZVidXCrAPLA8okpKSlAtjFI1ghZ1ggsbWIMhECeCYZuI0LGA+2PBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Personeel.In-/Extern" = _t, #"Uren Registratie 2.CategorieID" = _t, #"WBS Code" = _t, #"Klantnum." = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Personeel.In-/Extern", type text}, {"Uren Registratie 2.CategorieID", Int64.Type}, {"WBS Code", type text}, {"Klantnum.", Int64.Type}}), Custom1 = Table.ReplaceValue(#"Changed Type", each [Uren Registratie 2.CategorieID], each if [#"Personeel.In-/Extern"] = "Extern" and [WBS Code] = "731/7011.01" and [#"Klantnum."] =null then 6 else [Uren Registratie 2.CategorieID], Replacer.ReplaceValue,{"Uren Registratie 2.CategorieID"}) in Custom1
For overwriting the values, DAX can't be used. For this purpose, you will need to use PQ.
See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcq0oSS3KU9JRMgJic2NDfXMDQ0M9IAZyDZVidXCrAPLA8okpKSlAtjFI1ghZ1ggsbWIMhECeCYZuI0LGA+2PBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Personeel.In-/Extern" = _t, #"Uren Registratie 2.CategorieID" = _t, #"WBS Code" = _t, #"Klantnum." = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Personeel.In-/Extern", type text}, {"Uren Registratie 2.CategorieID", Int64.Type}, {"WBS Code", type text}, {"Klantnum.", Int64.Type}}),
Custom1 = Table.ReplaceValue(#"Changed Type", each [Uren Registratie 2.CategorieID], each if [#"Personeel.In-/Extern"] = "Extern" and [WBS Code] = "731/7011.01" and [#"Klantnum."] =null then 6 else [Uren Registratie 2.CategorieID], Replacer.ReplaceValue,{"Uren Registratie 2.CategorieID"})
in
Custom1- Anonymous4 years agoNot applicable
Hey Vijay,
Thanks for the quick response. I tried doing what you have suggested, but failed in doing so.
But I did try adding another step in PQ:
I've copy pasted then the last part of your code:
= Table.ReplaceValue(#"Namen van kolommen gewijzigd2", each [Uren Registratie 2.CategorieID], each if [#"Personeel.In-/Extern"] = "Extern" and [WBS Code] = "731/7011.01" and [#"Klantnum."] =null then 6 else [Uren Registratie 2.CategorieID], Replacer.ReplaceValue,{"Uren Registratie 2.CategorieID"})
I thought this would change the values of the table of the previous step, but it didn't. What am I doing wrong here?
With kind regards,
Lazzanova- Vijay_A_Verma4 years agoMost Valuable Professional
I am not sure whether your Klantnum. column is null or blanks. You can try following
= Table.ReplaceValue(#"Namen van kolommen gewijzigd2", each [Uren Registratie 2.CategorieID], each if [#"Personeel.In-/Extern"] = "Extern" and [WBS Code] = "731/7011.01" and ([#"Klantnum."] =null or [#"Klantnum."] ="") then 6 else [Uren Registratie 2.CategorieID], Replacer.ReplaceValue,{"Uren Registratie 2.CategorieID"})- Anonymous4 years agoNot applicable
The column has nulls, so the previous code would be correct. However, upon checking if the values have changed, I don't see any changes made.
If I would have had a typo regarding the column names, an error message would appear.
But that is also not the case. I can't explain why the values are not changing.
- Anonymous4 years agoNot applicable
The code you've posted here results in this query:
Not really sure why these values exist.
- Vijay_A_Verma4 years agoMost Valuable Professional
My source is a sample one, just for example. I need some sample data from your side to check on this. Also point out which value should have changed.
- Anonymous4 years agoNot applicable
Here is some sample data. I've deleted other columns.
See row 17: The value of 1 needs to change to 6.
(Because Klantnum. = empty / null) and WBS Code = 713/7011.01 and Personeel.In-/Extern = Extern (It shows null in PQ)Row Nr. Klantnum. Personeel.Naam WBS Code Uren Registratie 2.CategorieID Personeel.In-/Extern 1 1305030220 Önder Kandemir 713/7011.01 1 Extern 2 1305030211 Önder Kandemir 713/7011.01 1 Extern 3 1305030177 Önder Kandemir 713/7011.01 1 Extern 4 1305030228 Önder Kandemir 713/7011.01 1 Extern 5 1305030178 Önder Kandemir 713/7011.01 1 Extern 6 1305030019 Önder Kandemir 713/7011.01 1 Extern 7 1305030024 Önder Kandemir 713/7011.01 1 Extern 8 1305030195 Önder Kandemir 713/7011.01 1 Extern 9 1305030229 Önder Kandemir 713/7011.01 1 Extern 10 1305030120 Önder Kandemir 713/7011.01 1 Extern 11 1301020560 Önder Kandemir 713/7011.01 1 Extern 12 1305030171 Önder Kandemir 713/7011.01 1 Extern 13 1305030018 Önder Kandemir 713/7011.01 1 Extern 14 1305030120 Önder Kandemir 7040 6 Extern 15 1305030120 Önder Kandemir 7005 3 Extern 16 1305030191 Önder Kandemir 713/7011.01 1 Extern 17 Önder Kandemir 713/7011.01 1 Extern 18 Önder Kandemir 7045 3 Extern 19 Önder Kandemir 7005 3 Extern