Give this a go, just paste the script into a new blank query.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("rdO9DoMgEAfwd2F2Ob7UkZZqByexidH4/q/RptIE+Z8pgwPLL5fjPmBdBUklKuE+p3NDeIit+tmNsTtjnrHr8mljY75pfF1CTySPFIqiOqS+qIgZaUmJiCIl4yk0KWV+A0N0RgtSvk4Jq1MK135ugTHP2PHJaK3z8naakdwfMsbA3Ky12Gtdw5SaJm4+CfvaxFjPWPYT2vbQ1vYG", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Type = _t, #"T/F" = _t]),
ChType = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Type", type text}, {"T/F", type logical}}),
Solution =
Table.ExpandListColumn(
Table.Group( ChType, {"ID"},
{
{"Type", each _[Type]},
{"contains both X and Z", each List.ContainsAll( _[Type], { "X", "Z" }, Comparer.OrdinalIgnoreCase )},
{"contains X", each List.ContainsAny( _[Type], { "X" }, Comparer.OrdinalIgnoreCase )}
}
), "Type"
)
in
Solution
Please note there are some differences to the depicted results, for example
ID 122 should return true for all rows
ID 177 only returns true for contains “X”
ID 199 returns false on both because it only contains “Z”