cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
IvanS
Helper IV
Helper IV

Lookup returning value with earliest & latest date

Hi folks,

I am trying to calculate case duration (1 case consists of several tasks) and I amhaving issue with lookup function that should return the value with earlierst and also latest date. Example below:

 

I have 3 tables:

Table: DIM_DateTable (standard calculated date table)

 

Table: FACT_Cases with column:

  • Case_ID (distinct values in table)

Table: FACT_Tasks with columns:

  • Task_ID
  • Case_ID (not distinct values in table as several tasks can be related to 1 case)
  • Created date
  • Close date

I would need to calculate 2 columns in FACT_Case table with dates used in table FACT_Tasks:

  • Case created date (Earlierst created date of related tasks)
  • Case close date (Latest close date of related tasks)

Any help is much appreciated

IvanS

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@IvanS , new columns

Case start = minx(filter(Fact, Case_id = earlier([Case ID]) , [Created Date])

 

Case Closed= Maxx(filter(Fact, Case_id = earlier([Case ID]) , [Close Date])

 

Power BI DAX- Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8



!! Microsoft Fabric !!
Microsoft Power BI Learning Resources, 2023 !!
Learn Power BI - Full Course with Dec-2022, with Window, Index, Offset, 100+ Topics !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@IvanS , new columns

Case start = minx(filter(Fact, Case_id = earlier([Case ID]) , [Created Date])

 

Case Closed= Maxx(filter(Fact, Case_id = earlier([Case ID]) , [Close Date])

 

Power BI DAX- Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8



!! Microsoft Fabric !!
Microsoft Power BI Learning Resources, 2023 !!
Learn Power BI - Full Course with Dec-2022, with Window, Index, Offset, 100+ Topics !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!

Thank you for prompt help. Worked like a charm! 🙂

Helpful resources

Announcements
May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Submit your Data Story

Data Stories Gallery

Share your Data Story with the Community in the Data Stories Gallery.

Top Solution Authors