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
tuomas-i
Frequent Visitor

Using a certain value from a related table

I have two tables: Tasks and TaskBaselines

 

 

 

Tasks:
TaskId, TaskFinishDate

TaskBaselines: TaskId, TaskBaselineNumber, TaskBaselineFinishDate

 

 

I would like to get a DATEDIFF (in days) between the TaskFinishDate and the related TaskBaseline which has the highest TaskBaselineNumber (meaning it is the last baseline created).

 

I have tried meddling with it for some time but can't seem to find a way.

 

Link to some mockdata: https://drive.google.com/open?id=1FCQpVKCAmMa8NnC_kB2P--qknxzca_lT

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @tuomas-i,

 

Please create below measures:

highest baseline number =
CALCULATE (
    MAX ( TaskBaselines[BaselineNumber] ),
    ALLEXCEPT ( TaskBaselines, TaskBaselines[TaskId] )
)

Latestfinishtime =
CALCULATE (
    MAX ( TaskBaselines[TaskBaselineFinishDate] ),
    FILTER (
        ALL ( TaskBaselines ),
        TaskBaselines[BaselineNumber] = [highest baseline number]
            && TaskBaselines[TaskId] = SELECTEDVALUE ( Tasks[TaskId] )
    )
)

datediff =
DATEDIFF ( SELECTEDVALUE ( Tasks[TaskFinishDate] ), [Latestfinishtime], DAY )

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yulgu-msft
Employee
Employee

Hi @tuomas-i,

 

Please create below measures:

highest baseline number =
CALCULATE (
    MAX ( TaskBaselines[BaselineNumber] ),
    ALLEXCEPT ( TaskBaselines, TaskBaselines[TaskId] )
)

Latestfinishtime =
CALCULATE (
    MAX ( TaskBaselines[TaskBaselineFinishDate] ),
    FILTER (
        ALL ( TaskBaselines ),
        TaskBaselines[BaselineNumber] = [highest baseline number]
            && TaskBaselines[TaskId] = SELECTEDVALUE ( Tasks[TaskId] )
    )
)

datediff =
DATEDIFF ( SELECTEDVALUE ( Tasks[TaskFinishDate] ), [Latestfinishtime], DAY )

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
CheenuSing
Community Champion
Community Champion

Hi @tuomas-i

 

Please share some data on google drive or one-drive with the link posted here.  Also what is the exact output you desire.

 

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

Hi @CheenuSing,

 

Added a mockdata link to the opening post.

 

So I have projects, and I want to see how each project's TaskFinishDate compares to last created (highest BaselineNumber) baseline's TaskBaselineFinishDate.

 

So basically, I want a table with the following format (only the last column is relevant though):

 

[ProjectName], [TaskName], [TaskFinishDate minus highest BaselineNumber TaskBaselineFinishDate (in days)]

Example Project, Example Task, -3

 

Thus, that example project's task is projected to finish 3 days ahead of schedule. Whether a measure or calculated column is used, does not matter (even though a measure might be more convenient since there are a lot of tasks and no point in calculating that for each one).

 

 

 

 

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.