Forum Discussion

cosminc's avatar
cosminc
Post Partisan
7 years ago
Solved

DAX multiple table filters intersection

Hi all,

i have a base like below and need to create a measure with multiple filters intersection like this:

VAR

_first_filter all ID where Label = A and Value = 1

_second_filter all ID where Label = B and Value = 1

_third_filter all ID where Label = C and Value = 1

RESULT

and need to countrows of source from below with filters Label = C &&  all common ID between the 3 filter tables from above

 

Thanks in advance,

Cosmin

 

 
IDLabelValueClient
1A1cosmin
1B1cosmin
1C1cosmin
2A0cosmin
2B1cosmin
2C1cosmin
3A0cosmin
3B1cosmin
3C0cosmin
4A1cosmin
4B1cosmin
4C0cosmin
5A1cosmin
5B0cosmin
5C999cosmin
1A1marius
1B0marius
1C1marius
2A0marius
2B1marius
2C1marius
3A0marius
3B1marius
3C0marius
4A1marius
4B0marius
4C1marius
5A0marius
5B1marius
5C0marius
  • Hi cosminc ,

     

    Please refer to below measure:

    Count_rows =
    VAR temp_tab =
        ADDCOLUMNS (
            Sample4,
            "Label number", CALCULATE (
                DISTINCTCOUNT ( Sample4[Label] ),
                ALLEXCEPT ( Sample4, Sample4[ID] ),
                Sample4[Value] = 1
            )
        )
    RETURN
        COUNTROWS ( FILTER ( temp_tab, [Label number] = 3 && [Label] = "C" ) )

     

    Best regards,

    Yuliana Gu

2 Replies

  • v-yulgu-msft's avatar
    v-yulgu-msft
    Microsoft Employee

    Hi cosminc ,

     

    Please refer to below measure:

    Count_rows =
    VAR temp_tab =
        ADDCOLUMNS (
            Sample4,
            "Label number", CALCULATE (
                DISTINCTCOUNT ( Sample4[Label] ),
                ALLEXCEPT ( Sample4, Sample4[ID] ),
                Sample4[Value] = 1
            )
        )
    RETURN
        COUNTROWS ( FILTER ( temp_tab, [Label number] = 3 && [Label] = "C" ) )

     

    Best regards,

    Yuliana Gu

    • cosminc's avatar
      cosminc
      Post Partisan

      Perfect!

      Thanks,

      Cosmin