The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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!
Solved! Go to Solution.
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.
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
i get data from mysql directly. What should i do?
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"
showing this error
Second line which starts with actdb_incident, need to have a comma at the end.
In Replaces value line, Source should be replaced with actdb_incident_user_outcomes
Not working.
let
Source = MySQL.Database("maketimecount-enc.cqc9l79hnudu.eu-west-2.rds.amazonaws.com", "actdb", [ReturnSingleDatabase=true]),
actdb_incident_user_outcomes = Source{[Schema="actdb",Item="incident_user_outcomes"]}[Data]
in
actdb_incident_user_outcomes,
#"Replaced Value" = Table.actdb_incident_user_outcomes(Source,"",null,Replacer.actdb_incident_user_outcomes,{"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"
It was not properly merged. Use below one
let
Source = MySQL.Database("maketimecount-enc.cqc9l79hnudu.eu-west-2.rds.amazonaws.com", "actdb", [ReturnSingleDatabase=true]),
actdb_incident_user_outcomes = Source{[Schema="actdb",Item="incident_user_outcomes"]}[Data],
#"Replaced Value" = Table.actdb_incident_user_outcomes(actdb_incident_user_outcomes,"",null,Replacer.actdb_incident_user_outcomes,{"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"
showing this error. spellings are correct too.
Ok, I got an answer but in few rows it shows blank
Please paste the data alongwith column names where problem is
Will this code remove duplicates? If yes, then i do not want to remove duplicates.
No duplicates removed.