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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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