cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mattcameron Frequent Visitor
Frequent Visitor

DAX Column days since earliest date

Hi,

I have a table with column [Group] and column [Date]. I'm looking for a DAX formula that finds the earliest date for each group, and then adds a custom column that calculates the difference between that row date and the earliest date value for that group. 

So the following table...

 

img.PNG

 

Would result in somethign like the following:

 

img.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Omega Established Member
Established Member

Re: DAX Column days since earliest date

Try creating the below measure: 

 

Measure = 
var FirstDates = CALCULATE(FIRSTDATE(Table1[Date]),ALLEXCEPT(Table1,Table1[Group]))
var SelectedDate = CALCULATE(SELECTEDVALUE(Table1[Date]),ALLEXCEPT(Table1,Table1[Date]))
return
DATEDIFF(FirstDates,SelectedDate,DAY)
1 REPLY 1
Highlighted
Omega Established Member
Established Member

Re: DAX Column days since earliest date

Try creating the below measure: 

 

Measure = 
var FirstDates = CALCULATE(FIRSTDATE(Table1[Date]),ALLEXCEPT(Table1,Table1[Group]))
var SelectedDate = CALCULATE(SELECTEDVALUE(Table1[Date]),ALLEXCEPT(Table1,Table1[Date]))
return
DATEDIFF(FirstDates,SelectedDate,DAY)