Forum Discussion

1katznir's avatar
1katznir
Regular Visitor
5 years ago
Solved

Running Total Cohort DAX

Hola Tengo la siguiente tabla: first_day_of_month (por ejemplo, '2020-01-01') cohort_month (por ejemplo, 0, 1, 2, 3, etc.) customer_type (mensual, anual plan_type (básico, profesional, premi...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hola @1katznir

    Creo que desea calcular el total de ejecución para cada Start_OF_Month_Date por Cohort_Month.

    Y compare el gasto con la medida para calcular el mínimo Cohort_Month para cada Start_OF_Month.

    Construyo dos medidas:

    Running Total Booking Amount = 
    SUMX (
        FILTER (
            ALL ( BOOKING_MONTHLY_COHORT ),
            BOOKING_MONTHLY_COHORT[Start_OF_Month_Date]
                = MAX ( BOOKING_MONTHLY_COHORT[Start_OF_Month_Date] )
                && BOOKING_MONTHLY_COHORT[Cohort_Month]
                    <= MAX ( BOOKING_MONTHLY_COHORT[Cohort_Month] )
        ),
        BOOKING_MONTHLY_COHORT[Booking_Amount]
    )
    M.Cohort_Month = 
    VAR _RunningTotalExpense_Amount =
        SUMX (
            FILTER (
                ALL ( BOOKING_MONTHLY_COHORT ),
                BOOKING_MONTHLY_COHORT[Start_OF_Month_Date]
                    = MAX ( BOOKING_MONTHLY_COHORT[Start_OF_Month_Date] )
                    && BOOKING_MONTHLY_COHORT[Cohort_Month]
                        <= MAX ( BOOKING_MONTHLY_COHORT[Cohort_Month] )
            ),
            BOOKING_MONTHLY_COHORT[Expense_Amount]
        )
    VAR _COHORT =
        MINX (
            FILTER (
                ALL ( BOOKING_MONTHLY_COHORT ),
                BOOKING_MONTHLY_COHORT[Start_OF_Month_Date]
                    = MAX ( BOOKING_MONTHLY_COHORT[Start_OF_Month_Date] )
                    && [Running Total Booking Amount] >= _RunningTotalExpense_Amount
            ),
            BOOKING_MONTHLY_COHORT[Cohort_Month]
        )
    RETURN
    IF(NOT(ISBLANK(_COHORT)),IF(MAX(BOOKING_MONTHLY_COHORT[Cohort_Month])=_COHORT,_COHORT,BLANK()),BLANK())

    El resultado es el siguiente.

    1.png

    Puede descargar el archivo pbix desde este enlace: Ejecución de Total Cohort DAX

    Saludos

    Rico Zhou

    Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.