'How to filter table by two columns
I have the following table:
| ID | TEST_ID | Component | ComponentInfo |
|---|---|---|---|
| 1 | 5 | Test 1 | Info |
| 2 | 5 | Test 1 | AB 2 |
| 3 | 5 | Test 1 | XY |
| 4 | 5 | Test X | Info 2 |
| 5 | 5 | Test X | Info 1 |
| 6 | 5 | Test Y | Info 2 |
| 7 | 6 | Test 1 | Info 2 |
| 8 | 7 | ABC | Info 1 |
| 9 | 8 | XYZ | Info 2 |
| 9 | 9 | XYZ | Info 2 |
I like to get the following output:
| TEST_ID | Component |
|---|---|
| 5 | Test 1 |
| 5 | Test X |
| 5 | Test Y |
| 6 | Test 1 |
| 7 | ABC |
| 8 | XYZ |
| 9 | XYZ |
I think it would be nice to realize it in the data transformation part. How can I do that?
Solution 1:[1]
I don't see any filtering in your "question"; Rather, removing redundant columns and leaving unique values.
M language statement:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIF4pDU4hIFEMczLy1fKVYnWskIXcbRScEILGOMLhMRCRY3QRaPgJoF1WOKVc4QLGeGLBeJqs8cyDVDdx9UzgLINQc7zBnVQEsg1wLsrihUHSAJSwyJWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, TEST_ID = _t, Component = _t, ComponentInfo = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"TEST_ID", Int64.Type}, {"Component", type text}, {"ComponentInfo", type text}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"ID", "ComponentInfo"}),
#"Removed Duplicates" = Table.Distinct(#"Removed Columns")
in
#"Removed Duplicates"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | msta42a |
