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
Anonymous
Not applicable

Need help with the Datediff functionality

I am trying to calculate the date difference between two dates that can only be defined by another column. I have a table with three columns i.e taskname,taskstartdate, taskfinishdate

 

TaskName         TaskStartDate      TaskFinishDate

TaskName1       10/08/2017          01/08/2018

TaskName2       01/09/2018          05/04/2018

 

Now I need the date difference between Taskname1-TaskStartdate and Taskname2-TaskFinishdate so that I can calculate the total duration of the project from start to finish and I can't take the difference of the projectstartdate and projectfinishdate as there might be other tasks associated with the project that are beginning and ending before or after these tasks.

 

Any help would be apprieciated.

 

Thanks

Sridhar

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,

 

I tried different ways to calculate the date difference between two diffrent rows of two different colunms but I couldn't for abvious reasons. So we changed the underlying data to reflect that for any given task we shall have the start and the finish date for the corresponding taskname which are associated with the primary key(projectid). Then I can compute the date difference normally. For now this is the alternative workaround for this issue.

 

Thanks

Sridhar

View solution in original post

3 REPLIES 3
hemal_kanjia
Helper I
Helper I

@Anonymous

 

 

Try this Formula:

 

DATEDIFF(TaskStartDate,TaskFinishDate,Day)

 

 

 

-Hemal

Anonymous
Not applicable

@hemal_kanjia I tried that but the issue I am facing is that I need the datediff between taskname1-taskstartdate and taskname2-taskfinishdate. If I use the above formula it would only give me the date difference between taskname1-taskstartdate and taskfinishdate. I wrote a DAX query but I am not getting any output

 

Duration_Metric7 = DATEDIFF((IF('Tasks-Metric7'[TaskName]="Taskname2",'Tasks-Metric7'[TaskFinishDate].[Date])),(IF('Tasks-Metric7'[TaskName]="Taskname1",'Tasks-Metric7'[TaskStartDate] .[Date])),DAY)

 

Please let me know if you can tweak the above formula to compute the difference. Any help would be appreciated. 

Anonymous
Not applicable

Hi,

 

I tried different ways to calculate the date difference between two diffrent rows of two different colunms but I couldn't for abvious reasons. So we changed the underlying data to reflect that for any given task we shall have the start and the finish date for the corresponding taskname which are associated with the primary key(projectid). Then I can compute the date difference normally. For now this is the alternative workaround for this issue.

 

Thanks

Sridhar

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.