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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
qwertzuiop
Advocate III
Advocate III

Add Attributs form another table

Hi dear community

 

Following problem to solve:

I habe two tables (only an overview of data):

 

Table 1 contains information for which period an employee is assigned to which region / location / group (see picture)

 

qwertzuiop_0-1600688252658.png

 

qwertzuiop_2-1600688532129.png

 

Table 2 contains information about which shift an employee is working on a specific date

 

What to do? - In table 2, the information should be attached in which region / place / group the employees work.

I am very grateful for your support.


Cheers 
qwertzuiop

1 ACCEPTED SOLUTION

@qwertzuiop , New Columns like this in table 2

 

Area = maxx(filter(Table1, Table1[ID] =Table2[ID] && Table2[Date] >= Table1[Date_from] && Table2[Date] < = Table1[Date_to]),Table1[Area])

 

Same way repeat other two

 

Location = maxx(filter(Table1, Table1[ID] =Table2[ID] && Table2[Date] >= Table1[Date_from] && Table2[Date] < = Table1[Date_to]),Table1[Location])
Group = maxx(filter(Table1, Table1[ID] =Table2[ID] && Table2[Date] >= Table1[Date_from] && Table2[Date] < = Table1[Date_to]),Table1[Group])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

5 REPLIES 5
FuadAliyev
Frequent Visitor

Hi @qwertzuiop 

You can choose one of  2 solution.

1) Create a relationship with Table1(ID)-->Table2(ID) and create columns with Related() function . For example: create column in Table2 as Area=Related(Table1[Area]) and other columns

2)Use LOOKUPVALUE() Function without relations. for example: Create Column in Table2 as Area=LOOKUPVALUE(Table1[Area],Table1[ID],Table2[ID]) 

Thank you very much for your contribution, but I think it's not thas quick solved.

 

Why? Because the ID can/will occur several times in both tables, since the employee in table 1 may change the area every month and in table 2 he/she carry out a new shift every day.

 

So I have to check, in which time period (from-to) the date of the shift fits and matches the id.

Then it should be possible for me to tell you later, which employee performs a shift in which region based on the date.

 

Got it?

Thaaanks a lot.

 

Cheers

qwertzuiop

@qwertzuiop , New Columns like this in table 2

 

Area = maxx(filter(Table1, Table1[ID] =Table2[ID] && Table2[Date] >= Table1[Date_from] && Table2[Date] < = Table1[Date_to]),Table1[Area])

 

Same way repeat other two

 

Location = maxx(filter(Table1, Table1[ID] =Table2[ID] && Table2[Date] >= Table1[Date_from] && Table2[Date] < = Table1[Date_to]),Table1[Location])
Group = maxx(filter(Table1, Table1[ID] =Table2[ID] && Table2[Date] >= Table1[Date_from] && Table2[Date] < = Table1[Date_to]),Table1[Group])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak 

 

Sorry for my absence.

Thank you very much for your support.
The solution you gave me here works.

 

 

Have a nice day - you saved mine 😉

 

amitchandak
Super User
Super User

@qwertzuiop , I think a better idea to merge in power Bi. Select Table 2, merge Table1 and keep the required columns

https://radacad.com/append-vs-merge-in-power-bi-and-power-query

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.