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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Return value based on matching value & Date difference

Hello,

 

Having an issue figuring out how to gather information from a seperate table comparing two different columns. Below are examples of tables. Case Table holds all cases with the date the case was made and the email of who made it. While the Department table has the dates the employee was hired/changed departments (Job Date), the employee's email, and the current department the employee is in.

 

Case Table

CaseDate CreatedEmailDepartment
17/13/19John@job.com 
21/5/18Joe@job.com 
310/10/19John@job.com 

 

Department Table

Job DateEmployee EmailCurrent Department
5/5/18John@job.comCustomer Service
7/10/19John@job.comOperations
10/9/19John@job.comFinance
1/1/18Joe@job.comCustomer Service

 

I am trying to get the Current Department the employee was in at the time the case was created. Below is example of what completed case table would look like

Completed  Case Table

CaseDate CreatedEmailDepartment
17/13/19John@job.comCustomer Service
21/5/18Joe@job.comCustomer Service
310/10/19John@job.comFinance

 

I had tried using FirstNONBLANK, but cannot work a filter to compare the dates and pull the correct department.

 

 

Department = 
CALCULATE(
    FIRSTNONBLANK(DepartmentTable[CurrentDepartment], 1),
    FILTER(
        DepartmentTable,
        DepartmentTable[Employee Email] = CaseTable[Email]
               && AssociateLog[ModifiedDate] <= Complaints[Date]
    )
)

 

 

 

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hi @Anonymous 

try this calculated column

Department = lookupvalue(DepartmentTable[Current Department];DepartmentTable[Employee Email];[Email];DepartmentTable[Job Date];calculate(max(DepartmentTable[Job Date]);filter(all(DepartmentTable);DepartmentTable[Employee Email]=[Email] && DepartmentTable[Job Date]<=[Date Created])))

do not hesitate to give a kudo to useful posts and mark solutions as solution

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

3 REPLIES 3
bwarner87
Advocate I
Advocate I

this worked like a charm for me! thank you!

 

az38
Community Champion
Community Champion

Hi @Anonymous 

try this calculated column

Department = lookupvalue(DepartmentTable[Current Department];DepartmentTable[Employee Email];[Email];DepartmentTable[Job Date];calculate(max(DepartmentTable[Job Date]);filter(all(DepartmentTable);DepartmentTable[Employee Email]=[Email] && DepartmentTable[Job Date]<=[Date Created])))

do not hesitate to give a kudo to useful posts and mark solutions as solution

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

Hi @az38 

That worked perfect! Originally tried using Lookupvalue, but had no luck. Thank you!

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.