Select keyid for specific column not duplicate?

If i have a table as show below.

ID Name Type Qty
1 A Pork 1
2 B Pork 2
3 C Milk 3
4 D Milk 4

How should i select only not duplicate in column Type ?

If i use SELECT([Relate test][Type],True,True) , i only got list of Pork,Milk. But what i want is list of ID 1,3.

Solved Solved
0 6 292
1 ACCEPTED SOLUTION

Maybe this?

SELECT(
  [Related tests][ID],
  ISBLANK(
    FILTER(
      "tests",
      AND(
        ([_ROWNUMBER] < [_THISROW-1].[_ROWNUMBER]),
        IN([ID], [_THISROW].[Related tests]),
        ([Type] = [_THISROW-1].[Type])
      )
    )
  )
)

View solution in original post

6 REPLIES 6

Steve
Platinum 4
Platinum 4

Please post a screenshot of your expression.

I just want to select any key row of each Type.

Maybe this?

SELECT(
  [Related tests][ID],
  ISBLANK(
    FILTER(
      "tests",
      AND(
        ([_ROWNUMBER] < [_THISROW-1].[_ROWNUMBER]),
        IN([ID], [_THISROW].[Related tests]),
        ([Type] = [_THISROW-1].[Type])
      )
    )
  )
)

Work like miracle !!! Thank you very much, @Steve

I need to learn more about Filter now. Could you please explain more in details about this formula ? Why there have ISBLANK ? I am a bit confused.

The approach Iโ€™ve used is to include in the result only the first row of the tests table for each [Type] found in the rows identified by [Related tests].

The SELECT() expression looks through each row in [Related tests]. For each row, the FILTER() expression is performed to list the rows in tests that have the same [Type] value and that occur in the [Related tests] list and that have a lower row number. If there are no such rows (the result of FILTER() is an empty list, or โ€œis blankโ€), we know that the row weโ€™re examining is the one with the lowest row number for that [Type] value.

Thank you very much, @Steve

Top Labels in this Space