Forum Discussion

icturion's avatar
icturion
Resolver II
3 years ago
Solved

Filter tabel by same values in different rows

Can someone help me with a formula for a calculated column that makes it possible to show only records that have two items A and B within the same number?

 

Example data:

NRItem
1A
1B
2A
3A
3B
4A
5A
5C

 

THe result i'm looking for is:

NRItem
1A
1B
3A
3B
  • Here's a column expression that returns T/F for Numbers 1 and 3 rows.

     

     

    ABonly =
    VAR items =
        CALCULATETABLE ( DISTINCT ( T1[Item] ), ALLEXCEPT ( T1, T1[NR] ) )
    VAR AB = { "A", "B" }
    RETURN
        COUNTROWS ( INTERSECT ( items, AB ) ) = 2
            && COUNTROWS ( items ) = 2

     

    Pat

1 Reply

  • ppm1's avatar
    ppm1
    Solution Sage

    Here's a column expression that returns T/F for Numbers 1 and 3 rows.

     

     

    ABonly =
    VAR items =
        CALCULATETABLE ( DISTINCT ( T1[Item] ), ALLEXCEPT ( T1, T1[NR] ) )
    VAR AB = { "A", "B" }
    RETURN
        COUNTROWS ( INTERSECT ( items, AB ) ) = 2
            && COUNTROWS ( items ) = 2

     

    Pat