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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Auski
Helper I
Helper I

LOOKUP between two dates with related Email

Hi all,
I have looked at similar threads here for a solution, but haven't been very successful finding a suitable solution. This is somewhat of a non standard lookup....

I have two tables; 'Org Chart' and 'Cases'. The relationship of these tables is "Email".

The 'Org Chart' table contains a WEEKLY snapshot (including history) of my company's organisation chart over the past 5 years -which means there is a lot of duplicate data within the table. This table contains 'Employee Role' and a 'Start of Week' field and an 'End of Week' field.

Org Chart.jpg
  

 

 

 

 

 

The 'Cases' table contains a case created date, however it does not contain Employee Role

Old Cases.jpg




 

 

 

 

 

 

 

 

 

I would like to create a column in Cases that looks at created date and returns the Employee Role BETWEEN the related 'Start of Week' and 'End of Week' fields.

The expected outcome would be:

New Cases.jpg

 

 

 

 

 

 

 

I hope that makes sense.... please let me know if it is not clear.

Thanks so much 🙂




Cases

EmailCreated Date
joe.blow@company.com25/04/2024
joe.blow@company.com27/04/2024
joe.blow@company.com24/04/2024
jane.blow@company.com26/02/2024
jane.blow@company.com27/04/2024
joe.blow@company.com26/04/2024
jane.blow@company.com22/02/2024
josh.blow@company.com26/04/2024
jess.blow@company.com15/03/2023
josh.blow@company.com27/12/2023
jess.blow@company.com27/04/2024
jane.blow@company.com24/04/2024


Org Chart

EmailStart of WeekEnd of WeekEmployee Role
joe.blow@company.com24/04/20241/05/2024Data Analyst
joe.blow@company.com24/04/20241/05/2024Data Analyst
jane.blow@company.com20/02/202427/02/2024Sales Officer
jane.blow@company.com20/02/202427/02/2024Sales Officer
josh.blow@company.com24/04/20241/05/2024Data Analyst
jess.blow@company.com9/03/202316/03/2023Marketing Coordinator
josh.blow@company.com24/12/202331/12/2023Sales Officer
jess.blow@company.com9/03/202316/03/2023Marketing Coordinator
joe.blow@company.com24/04/20241/05/2024Data Analyst
jane.blow@company.com24/04/20241/05/2024Team Leader
josh.blow@company.com24/12/202331/12/2023Sales Officer
jess.blow@company.com24/04/20241/05/2024General Manager

 

 

3 REPLIES 3
Auski
Helper I
Helper I

Thank you both very much for your assistance here. Both options work here as a solution, however I am dealing with huge volumes of data (over 3million rows in each of the tables). Each of these calculations take over 20mins to complete.

Perhaps a calculated column isn't the best way to go(?) - performance wise. Interested to hear your thoughts!

Ashish_Mathur
Super User
Super User

Hi,

Write this calculated column formula in the Cases table

Column = CALCULATE(MAX('Org chart'[Employee Role]),FILTER('Org chart','Org chart'[Start of Week]<=EARLIER('Cases'[Created Date])&&'Org chart'[End of Week]>=EARLIER('Cases'[Created Date])&&'Org chart'[Email]=EARLIER('Cases'[Email])))

Ashish_Mathur_0-1714532913038.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new column.

 

Jihwan_Kim_0-1714532041176.png

 

 

Employee Role CC =
SUMMARIZE (
    FILTER (
        SUMMARIZE (
            'org chart',
            'org chart'[Email],
            'org chart'[Start of Week],
            'org chart'[End of Week],
            'org chart'[Employee Role]
        ),
        'org chart'[Email] = 'cases'[Email]
            && 'org chart'[Start of Week] <= 'cases'[Created Date]
            && 'org chart'[End of Week] >= 'cases'[Created Date]
    ),
    'org chart'[Employee Role]
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.