Forum Discussion

Hems's avatar
Hems
Frequent Visitor
4 years ago
Solved

Count rows and group by on multiple columns

InputOutput

 

Columns are from different tables and need to get similar output using DAX

  • Hi Hems ,

    According to your description, here's my solution.

    Create a measure.

     

    Count =
    CALCULATE (
        COUNT ( 'Table'[id] ),
        FILTER ( ALL ( 'Table' ), 'Table'[col1] = MAX ( 'Table'[col1] ) ),
        FILTER ( ALL ( 'Table2' ), 'Table2'[col2] = MAX ( 'Table2'[col2] ) )
    )
    

     

    Get the expected result.

    I attach my sample below for reference.

     

    Best Regards,
    Community Support Team _ kalyj

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Hems , Based on what I got

     

    new column =

    Countx(filter(Table, [Col1] =earlier([Col1]) && [Col2] =earlier([Col2]) ), [ID] )

  • Hi Hems ,

    According to your description, here's my solution.

    Create a measure.

     

    Count =
    CALCULATE (
        COUNT ( 'Table'[id] ),
        FILTER ( ALL ( 'Table' ), 'Table'[col1] = MAX ( 'Table'[col1] ) ),
        FILTER ( ALL ( 'Table2' ), 'Table2'[col2] = MAX ( 'Table2'[col2] ) )
    )
    

     

    Get the expected result.

    I attach my sample below for reference.

     

    Best Regards,
    Community Support Team _ kalyj

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.