Forum Discussion

Dawson16's avatar
Dawson16
Frequent Visitor
4 years ago
Solved

Finding Change in Start Date Between Snapshots

Hello, I've been trying to create a calculated column in my workbook that calculates the change in start date for each Activity ID since the last snapshot was taken. Snapshots are taken on the first of every month, and activities could move forward, backward, stay the same, be completed or cancelled, or be newly added in each snapshot. I can't figure out how to create this formula in DAX, so I was wondering if someone would be able to help me out? I've included a sample image of what I'm going for below with the highlighted column being the one I'm trying to create. I really appreciate any help anyone can offer!

 

  • You could create a column like

    Start Date Diff =
    var currentID = 'Table'[Activity ID]
    var currentStartDate = 'Table'[Start Date]
    var currentSnapshot = 'Table'[Snapshot Date]
    var prevStartDate = LOOKUPVALUE( 'Table'[Start Date], 'Table'[Activity ID], currentID,
    'Table'[Snapshot Date], EOMONTH(currentSnapshot, -2) + 1
    return currentStartDate - prevStartDate

4 Replies

  • You could create a column like

    Start Date Diff =
    var currentID = 'Table'[Activity ID]
    var currentStartDate = 'Table'[Start Date]
    var currentSnapshot = 'Table'[Snapshot Date]
    var prevStartDate = LOOKUPVALUE( 'Table'[Start Date], 'Table'[Activity ID], currentID,
    'Table'[Snapshot Date], EOMONTH(currentSnapshot, -2) + 1
    return currentStartDate - prevStartDate
    • Dawson16's avatar
      Dawson16
      Frequent Visitor

      Thank you for the quick answer. When I use this formula for my column, the result is either the same as that row's Start Date or December 30, 1899. If I format the column as a whole number, the difference is in the 43,000s or is 0. Do you know what might be going wrong?

      • johnt75's avatar
        johnt75
        Icon for Super User rankSuper User

        I would start by changing the return statement to return each of the variables in turn, e.g.

        return currentID

        and then check the values in the column to see if they are what you would expect. That should help to identify where the problem lies