Forum Discussion

GRT9791's avatar
GRT9791
Frequent Visitor
1 year ago
Solved

Count non recurrent customers

Hello, I have to solve a complex calculation. I have a Date table and a table of client accesses to an application (Accesos). I need to create a table visualization in Power BI with the Year-Month ...
  • johnt75's avatar
    johnt75
    1 year ago

    This might work

    Number of first time clients =
    VAR ClientsWithFirstAccess =
        CALCULATETABLE (
            ADDCOLUMNS (
                VALUES ( '01.Accessos'[Cliente_Digital] ),
                "@first access", CALCULATE ( MIN ( '01.Accessos'[fecha_hora_operacion] ) )
            ),
            ALLSELECTED ( '02. Fecha' )
        )
    VAR Result =
        CALCULATE (
            DISTINCTCOUNT ( '01.Accessos'[Cliente_Digital] ),
            KEEPFILTERS (
                TREATAS (
                    ClientsWithFirstAccess,
                    '01.Accessos'[Cliente_Digital],
                    '02. Fecha'[05. Fecha]
                )
            )
        )
    RETURN
        Result
    

    It first builds a table of all clients and their first access times within the selected period, and then uses it as a filter, merging with any existing filter on the date table.