Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Promedio en powerbi

Buenas tardes, necesito ayuda con un problema en powerbi, cuento con la siguiente tabla

"cliente, fecha de visita"

Cli1, 01/01/2022

Cli1, 02/01/2022

Cli 2, 01/01/2022

Cli 2, 02/01/2022

Cli 2, 03/01/2022

Yo quiero mostrar en un dashboard el promedio mensual de visitas de mis clientes por lo que la tabla resultante seria

 

"Mes,promedio de visitas"

Enero , (2+3)/2=2,5

 

Hay alguna forma de calcular esto?

 

Muchas gracias

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    Please try:

    average =
    CALCULATE (
        COUNTROWS ( 'Table' ) / DISTINCTCOUNT ( 'Table'[Client] ),
        FILTER (
            'Table',
            YEAR ( [date of visit] ) = YEAR ( MAX ( 'Table'[date of visit] ) )
                && MONTH ( [date of visit] ) = MONTH ( MAX ( 'Table'[date of visit] ) )
        )
    )
    

    Output:

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

2 Replies

  • Anonymous , A measure like

     

    AverageX(summarize(Table, Table[Client], "_sum", Count(Table[fecha de visita])), [_sum])

     

    or add month year column in table and then have

     

    Month Year = format(Table[fecha de visita], "YYYYMM")

     

     

    measure =
    AverageX(summarize(Table, Table[Client], Table[Month Year], "_sum", Count(Table[fecha de visita])), [_sum])

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Please try:

    average =
    CALCULATE (
        COUNTROWS ( 'Table' ) / DISTINCTCOUNT ( 'Table'[Client] ),
        FILTER (
            'Table',
            YEAR ( [date of visit] ) = YEAR ( MAX ( 'Table'[date of visit] ) )
                && MONTH ( [date of visit] ) = MONTH ( MAX ( 'Table'[date of visit] ) )
        )
    )
    

    Output:

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