Forum Discussion

Khomotjo's avatar
Khomotjo
Helper II
1 year ago
Solved

Shift a Measure one Date Down

Hello Everyone,

 

I have atable like this : 

I woulk like to shift the measure down by one date so that 17 alighns with the 20th and 42 alighns with the 19th etc.

 

This is how I am calculating the measure :

 

Today Orders Test = CALCULATE(
    COUNT(Orders[Reference]),
    FILTER(Orders,TRUNC(Orders[Required Date])=TRUNC(Orders[Date]+1) && Orders[Status] <> "Departed")
)
 
Also note that Date refers to the analysis date i.e I run a report on the 25th to analyse performance for the 24th Therefore the date will be 24th. But Today's orders will be whatever orders are required on the day the report was ran hence required date = Date + 1
  • Hey there!

     

    To shift the measure down by one date, so that values from a particular date align with the next date in the table, you need to modify your DAX calculation to reference the previous day's value.

     

    Try this: 

    Shifted Today Orders Test =
    VAR CurrentDate = SELECTEDVALUE(Orders[Date])

    RETURN
    CALCULATE(
    [Today Orders Test],
    Orders[Date] = CurrentDate - 1
    )

     

    Hope this helps!

    😁😁

2 Replies

  • freginier's avatar
    freginier
    Solution Sage

    Hey there!

     

    To shift the measure down by one date, so that values from a particular date align with the next date in the table, you need to modify your DAX calculation to reference the previous day's value.

     

    Try this: 

    Shifted Today Orders Test =
    VAR CurrentDate = SELECTEDVALUE(Orders[Date])

    RETURN
    CALCULATE(
    [Today Orders Test],
    Orders[Date] = CurrentDate - 1
    )

     

    Hope this helps!

    😁😁

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Khomotjo 

    I notice that the dates are not consecutive, which previous date should be chosen when the date is not consecutive? Let's take 2025/2/17 as an example, its previous date in the table visual is 2025/2/12, do you want to get the value on this date? Or do you want to get the count value of 2025/2/16? Minusing 1 from the current date will only give you the previous calendar date. Not sure which one is what you expect? 

     

    Best Regards,
    Jing