Forum Discussion
Create new column from existing columns
From above table i want to create a new column(yellow color) and get the data from existing columns(orange color).
Priority should be as below:
1_ override_outcome
2_ final_recommendation_outcome
3_ recomanded_outcome
4_ stander_outcome.
Do let me know if you need more clarification on this. THANK YOU IN ADVANCE!
Please paste the data alongwith column names where problem is
14 Replies
- Vijay_A_VermaMost Valuable Professional
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"- hello_MTCHelper III
Will this code remove duplicates? If yes, then i do not want to remove duplicates.
- Vijay_A_VermaMost Valuable Professional
No duplicates removed.
- hello_MTCHelper III
The code is working but not getting what i want. May be i misunderstood the concept. It fetches less data.
- Vijay_A_VermaMost 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