Forum Discussion
Arnaudd
2 years agoNew Member
Conditional column based on data from different rows and same user
Hello , I have the date as in the below power BI table, I want to modify column [PassY/N] or create a new conditional column, based on the below cretaia: if there are two rows rows for the ...
- 2 years ago
lbendlin
2 years agoSuper User
Group your data by user. Add one aggregation for "Count of rows" and another aggregation for "Maximum of [pass(Y/N)]"
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIEYr98pVidaCUnVK4zlBuZWgzmO6LxQcqNkPguSNpjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [user = _t, #"number of test" = _t, #"pass(Y/N)" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"number of test", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"user"}, {{"Total number of test", each Table.RowCount(_), Int64.Type}, {"pass(Y/N)", each List.Max([#"pass(Y/N)"]), type nullable text}})
in
#"Grouped Rows"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the Source step with your own source.