Forum Discussion
joshua1990
Post Prodigy
4 years agoTRUE FALSE if group contains value
Hi experts! I would like to get a TRUE/FALSE if a group contains a specific value. The structure is like this: Order Nr Value TRUE / FALSE 100 A TRUE 100 B TRUE 102 A FALSE ...
- 4 years ago
Group by Order; then aggregate by the testing if the Value in each group contains "B":
let //change next line to reflect your actual source of data Source = Excel.CurrentWorkbook(){[Name="Table5"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"Order Nr", Int64.Type}, {"Value", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Order Nr"}, { {"Grouped", each _, type table [Value=nullable text]}, {"TRUE/FALSE", each List.Contains([Value],"B"), type logical} }), #"Expanded Grouped" = Table.ExpandTableColumn(#"Grouped Rows", "Grouped", {"Value"}, {"Value"}) in #"Expanded Grouped"
Vijay_A_Verma
Most Valuable Professional
4 years agoBelow is an alternative solution. Put following in a custom column (Replace #"Changed Type" with your previous step)
= List.Contains(List.Zip({#"Changed Type"[Order Nr],#"Changed Type"[Value]}),{[Order Nr],"B"})Marginal performance to the tune of 10-20% can be gained by buffering the lists if you have got thousands of records. These 2 lists are - #"Changed Type"[Order Nr] and #"Changed Type"[Value].