Selecting only single rows from a number of single source-multiple values

Viewed 23

I have a table that looks like this:

Source   | Values
------------------------
Tester   | Sample01
Tester   | AnotherSample
Tester   | Samples
Tester2  | Isitasample
Tester2  | sampledagain
Tester2  | testdata
Tester3  | approximation
Tester3  | <null>

and as a result I only want to have a single entry from each source, like:

Source   | Values
-----------------------
Tester   | Sample01
Tester2  | sampledagain
Tester3  | <null>

I have thought about distinct and join but I can only come up with solutions that filter out values alltogether. Same with unions. I am stumped.

1 Answers
let t = datatable (Source:string, Values:string)
[
     'Tester'  ,'Sample01'
    ,'Tester'  ,'AnotherSample'
    ,'Tester'  ,'Samples'
    ,'Tester2'  ,'Isitasample'
    ,'Tester2' ,'sampledagain'
    ,'Tester2' ,'testdata'
    ,'Tester3' ,'approximation'
    ,'Tester3' ,'<null>'
];
// Option 1
t
| summarize arg_max("", *) by Source
| project-away max_
Source Values
Tester Sample01
Tester2 Isitasample
Tester3 approximation

Fiddle

Related