Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Dawson16
Frequent Visitor

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!

Dawson16_0-1657032480124.png

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

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

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

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

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?

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

Thanks John, this worked for what I was going for!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors