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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
neees78
Helper II
Helper II

Calculated Column based on another table

Hello All, 

I've two tables in my project - no relationship exists

Table 1 

dt.startdt.end  jobtyp
13/06/2022 00:1513/06/2022 01:30Travel
17/06/2022 17:4518/06/2022 10:00Travel
28/06/2022 23:1528/06/2022 23:30Travel
07/07/2022 03:3007/07/2022 06:00Travel
24/07/2022 07:3024/07/2022 12:00Logging 
02/08/2022 18:3002/08/2022 20:00Logging 
02/08/2022 20:3002/08/2022 23:00Logging 

 

Table2

jobtypdt.startdt.end
Travel03/06/2022 11:0015/07/2022 00:00
Logging 22/07/2022 06:3003/08/2022 23:00

 

on Table1 - is it possible to have jobtyp column calculated based on Table2 jobtyp value 

using date values only 

 

if Table1(dt.start) >= Table2(dt.start) && Table1(dt.end)<= Table2(dt.end)

then return jobtyp value from Table2

 

Thanks in advance 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@neees78 Try:

Column = MAXX(FILTER('Table2', Table1[dt.start] >= Table2[dt.start] && Table1[dt.end] <= Table2[dt.end]), [jobtyp])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
neees78
Helper II
Helper II

@Greg_Deckler  if I have an ID column in both tables, can we add a condition or second filter to make sure it returns correct [jobtyp] or that row, what I found is that some jobs do cross over in times, thus it returns the first [jobtyp] within that time interval. 

 

regards 

 

Greg_Deckler
Super User
Super User

@neees78 Try:

Column = MAXX(FILTER('Table2', Table1[dt.start] >= Table2[dt.start] && Table1[dt.end] <= Table2[dt.end]), [jobtyp])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler   thanks a lot - it worked perfectly well 

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.