Forum Discussion

fabiomanniti's avatar
fabiomanniti
Helper III
4 years ago
Solved

Count rows from a group by table with filter

I hope you can help me: I have two tables: a dimension and a fact table for users. I would like to find how many users have registered twice based on the VAT number. So I want to do a group by VAT...
  • johnt75's avatar
    4 years ago

    You could try

    Num duplicate customers =
    VAR summaryTable =
        CALCULATETABLE (
            ADDCOLUMNS (
                SUMMARIZE ( dim_users, dim_users[VAT] ),
                "@num rows", CALCULATE ( COUNTROWS ( dim_users ) )
            ),
            dim_users[is_last_snap] = TRUE ()
        )
    RETURN
        COUNTROWS ( FILTER ( summaryTable, [@num rows] > 1 ) )