Forum Discussion
markabdey
5 years agoFrequent Visitor
Where Clause for Custom Column
Hi In Power Query I'm trying to create a Custom Column that is populated by a value from another column in the same table where a flag is set to 'Y'. I can't seem to get the right syntax in M to get...
- 5 years ago
Hi markabdey
Place the following M code in a blank query to see the steps.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjC3MjY4tEBJR8lPKVYHzDcxBfMjIXwLKwO4fCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Time = _t, Flag = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Time", type time}, {"Flag", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each #"Changed Type"{[Flag="Y"]}[Time], type time) in #"Added Custom"Please accept the solution when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
mahoneypat
5 years agoMicrosoft Employee
This would be easier with DAX but it can be done in the query editor too. Will all rows have the same value in that column (as with your example), or are there other columns and the Y value within a group needs to be found? If the latter, please update your example data to reflect that so you get what you need.
Pat
- markabdey5 years agoFrequent Visitor
Thanks for your reply. The value will be the same across all the rows.