Forum Discussion
Create new column from existing columns
- 4 years ago
Please paste the data alongwith column names where problem is
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)
If you already getting nulls in place of space, then #"Replaced Value" step is not required for you.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Xc47DoAgEATQu1BT8BGB0k+tEUvC/a8hDAtBEpaYvJmVGJlknCnr823yHG3qR+KRqRJwYgjQKaiBcm6H3l4QUC0Q/nUD1aP2SPEVvkzr777dws3Yv2r9gjv4Sr7l2WnHCfdwS/7Uamh/lwLsiPN529vSBw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, incident_id = _t, user_id = _t, stander_outcome = _t, recomanded_outcome = _t, override_outcome = _t, final_rcommendation_outcome = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"id", Int64.Type}, {"incident_id", Int64.Type}, {"user_id", Int64.Type}, {"stander_outcome", type text}, {"recomanded_outcome", type text}, {"override_outcome", type text}, {"final_rcommendation_outcome", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","",null,Replacer.ReplaceValue,{"stander_outcome", "recomanded_outcome", "override_outcome", "final_rcommendation_outcome"}),
#"Added Custom" = Table.AddColumn(#"Replaced Value", "latest", each List.RemoveNulls({[override_outcome]}&{[final_rcommendation_outcome]}&{[recomanded_outcome]}&{[stander_outcome]}){0})
in
#"Added Custom"
The code is working but not getting what i want. May be i misunderstood the concept. It fetches less data.
- Vijay_A_Verma4 years ago
Most Valuable Professional
This is just a sample data. You will need to replace my Source with your Source statement.
I have prepared one sample Excel for you - https://1drv.ms/x/s!Akd5y6ruJhvhuV-NEWdTWmdahgPs?e=f9G5eE
- hello_MTC4 years ago
Helper III
i get data from mysql directly. What should i do?
- Vijay_A_Verma4 years ago
Most Valuable Professional
1. Import data from Mysql into Power Query.
2. Open the Advanced Editor
Put following code after Source statement
#"Replaced Value" = Table.ReplaceValue(Source,"",null,Replacer.ReplaceValue,{"stander_outcome", "recomanded_outcome", "override_outcome", "final_rcommendation_outcome"}), #"Added Custom" = Table.AddColumn(#"Replaced Value", "latest", each List.RemoveNulls({[override_outcome]}&{[final_rcommendation_outcome]}&{[recomanded_outcome]}&{[stander_outcome]}){0}) in #"Added Custom"