Forum Discussion

crodrigueza's avatar
crodrigueza
Regular Visitor
4 years ago
Solved

filter a table excluding selected elements

Hi, 

 

I would like to make a count on a table, but excluding first some elements in another table. The next example may clarify the situation:

 

Table A:

 

UserProduct
AProduct A
BProduct B
CProduct B
DProduct B
EProduct A
FProduct C

 

Table B:

 

UserEmail
A[email protected]
B[email protected]
C[email protected]
D[email protected]
E[email protected]
F[email protected]
G[email protected]
H[email protected]
I[email protected]

 

Table A and Table B will have a relationship of 1:1 by user. Filtering table A by "Product A", I would like to count the users in table B different from those filtered in Table A:

 

Table B filtered:

 

UserEmail
B[email protected]
C[email protected]
D[email protected]
F[email protected]
G[email protected]
H[email protected]
I[email protected]

 

And the count result should be 7. Any ideas on how to achieve it?

 

Best regards, 

 

Carlos

 

  • Hi, crodrigueza 

     

    Since you have created a one-to-one relationship in two tables.

    You can directly create the measure like this:

    Measure = var a= COUNTROWS(TableB)
    var b=COUNTROWS(ALL(TableB))
    return b-a

    Did I answer your question? Please mark my reply as solution. Thank you very much.
    If not, please feel free to ask me.

    Best Regards,
    Community Support Team _ Janey

1 Reply

  • v-janeyg-msft's avatar
    v-janeyg-msft
    Community Support

    Hi, crodrigueza 

     

    Since you have created a one-to-one relationship in two tables.

    You can directly create the measure like this:

    Measure = var a= COUNTROWS(TableB)
    var b=COUNTROWS(ALL(TableB))
    return b-a

    Did I answer your question? Please mark my reply as solution. Thank you very much.
    If not, please feel free to ask me.

    Best Regards,
    Community Support Team _ Janey