Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Icon for Administrator rankAdministrator
1 year ago
Solved

Achieve a KPI with correct values for current and target

Good days to all I'm trying to visualize a KPI with current values (previous week) and the target the same week of the previous year (-51 weeks) For the objective everything is perfect, because it...
  • Bibiano_Geraldo's avatar
    1 year ago

    Hi Syndicate_Admin ,

    Please try the following Sales Total for the Previous Week DAX measure:

    v_Ventas_Valor_SemanaAnteriorTotal = 
    VAR FechaHoy = TODAY()
    VAR DiaSemanaHoy = WEEKDAY(FechaHoy, 2)  -- Monday = 1, Sunday = 7
    VAR FechaInicioSemanaAnterior = FechaHoy - DiaSemanaHoy - 6  -- Start of last week
    VAR FechaFinSemanaAnterior = FechaInicioSemanaAnterior + 6  -- End of last week
    
    RETURN
    CALCULATE(
        SUM(EncargosAnx[importe]),
        EncargosAnx[fecha] >= FechaInicioSemanaAnterior &&
        EncargosAnx[fecha] <= FechaFinSemanaAnterior
    )

     

    Sales Total for the Same Week Last Year

    v_Ventas_Valor_AnioPasado_SemanaAnterior = 
    VAR FechaHoy = TODAY()
    VAR DiaSemanaHoy = WEEKDAY(FechaHoy, 2)  -- Monday = 1, Sunday = 7
    VAR FechaInicioSemanaAnterior = FechaHoy - DiaSemanaHoy - 6  -- Start of last week
    VAR FechaInicioSemanaAnioAnterior = FechaInicioSemanaAnterior - 365  -- Start of same week last year
    VAR FechaFinSemanaAnioAnterior = FechaInicioSemanaAnioAnterior + 6  -- End of same week last year
    
    RETURN
    CALCULATE(
        SUM(EncargosAnx[importe]),
        EncargosAnx[fecha] >= FechaInicioSemanaAnioAnterior &&
        EncargosAnx[fecha] <= FechaFinSemanaAnioAnterior
    )

     

    If the logic still doesn’t work as expected, please let me know.