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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
kky1
Helper II
Helper II

Help adding column from another table with many to many relationship

I am stumped trying to add a column from one table to another which have a many to many relationship.

The two tables are for a calendar visual - one table has date/time start times and the other has date/time end times for the calendar.

 

I tried creating an ID table with one to many relationships to both of these tables, but the calendar visual doesn't recognize the relationship between the times tables and won't work. 

 

Ideally, I need one table with the start times end times. When I tried merge tables, it shows Table link. Is there a way to merge only the end times to the start time table in a way that is accurate by id and day name?

 

I've looked at relatedtable function but can't seem to get it to work the way I want. 

 

Here is the data inside the two tables:

 

Start Time table:

calendar start timescalendar start times

End Time Table:

calendar end timescalendar end times

 

All of the columns in both tables after the start/end time are calculated columns to get the current date for the day of the week. 

 

I tried linking the two tables on id and day name, but the calendar then shows multiple entries for every employee with every start and end time on the calendar (not correct data).

 

If anyone could assist with which DAX function I can use to achieve this, I'd be most grateful.

 

1 ACCEPTED SOLUTION
kky1
Helper II
Helper II

Hello - I figured out a solution for this which I'll post for anyone such as myself who is still in the learning stages of DAX. I'm sure it's not the most efficient way, but it worked for me.

 

I did a merge tables action which created a table with all of the data. In the new Merge table, I redid the calculations to gather the current weekday and created a date/time field for start and end dates. This created a table with a huge amount of duplicates where the start day name and end day names didn't match due to the many to many relationship.

 

So, I created a new column within the table to compare the two day names with "Yes" if they matched and "No" if they didn't. Then I just created a filter on my visual page for only those with a "Yes". This did the trick. Below are screenshots in case this helps anyone. 

Merged table with many values from the start time and end time table;

pic1.JPG

 

Added column to merged table to check if the day names matched.

 

pic2.JPG

Finished calendar now shows one entry per employee per day.

 

pic3.JPG

 

 

View solution in original post

1 REPLY 1
kky1
Helper II
Helper II

Hello - I figured out a solution for this which I'll post for anyone such as myself who is still in the learning stages of DAX. I'm sure it's not the most efficient way, but it worked for me.

 

I did a merge tables action which created a table with all of the data. In the new Merge table, I redid the calculations to gather the current weekday and created a date/time field for start and end dates. This created a table with a huge amount of duplicates where the start day name and end day names didn't match due to the many to many relationship.

 

So, I created a new column within the table to compare the two day names with "Yes" if they matched and "No" if they didn't. Then I just created a filter on my visual page for only those with a "Yes". This did the trick. Below are screenshots in case this helps anyone. 

Merged table with many values from the start time and end time table;

pic1.JPG

 

Added column to merged table to check if the day names matched.

 

pic2.JPG

Finished calendar now shows one entry per employee per day.

 

pic3.JPG

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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