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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
febing
Frequent Visitor

Join 2 Tables and replace values in the master table based on data in exception table

Hi

I am pretty new to Power BI. Have a very basic question. I am preparing a roster report on a calendar matrix view based on excel data.

 

I have 2 tables - Master Roster Table which gives the data for a month and then there is a Roster Exception table. My requirement is I need to merge these 2 tables using employeeid and Schedule date as the join criteria and if records are found in the roster exception table, then the master roster table should be updated with these column values and new flag to be introduced saying that this is an exception roster.

 

How can we achieve this. I know its a very basic quetion. Pretty new to these things. Any pointers will be of great help

 

Regards

Febin Gafoor

1 ACCEPTED SOLUTION
jgeddes
Super User
Super User

Here is an example that might help...
If you have two tables such as,

'masterTable'

jgeddes_0-1707839140100.png

'exceptionTable'

jgeddes_1-1707839151493.png

You can merge the 'exceptionTable' into the 'masterTable' using the ID and Date columns as the key.

jgeddes_2-1707839242284.png

Expand only the exceptionValue in the merged column.

jgeddes_3-1707839315659.png

Your table should now look something like...

jgeddes_4-1707839362526.png

Add a column that determines which table's value we will end up with.

jgeddes_5-1707839412948.png

Now select the 'exceptionValue' column and choose 'Replace Values' from the 'Transform' ribbon...
Use 'null' as the value to find and a random number as the 'Replace With' value. It does not matter what number as we are changing it right away.

jgeddes_6-1707839572076.png

The function value should populate with...

jgeddes_8-1707839650553.png

Replace the '99999' with 'each [masterValue] and you should end up with...

jgeddes_9-1707839715242.png

You can now change remove the masterValue column if you do not need it for other purposes, change data types and rename columns as desired to end up with...

jgeddes_10-1707839799392.png

Hope this helps.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

2 REPLIES 2
jgeddes
Super User
Super User

Here is an example that might help...
If you have two tables such as,

'masterTable'

jgeddes_0-1707839140100.png

'exceptionTable'

jgeddes_1-1707839151493.png

You can merge the 'exceptionTable' into the 'masterTable' using the ID and Date columns as the key.

jgeddes_2-1707839242284.png

Expand only the exceptionValue in the merged column.

jgeddes_3-1707839315659.png

Your table should now look something like...

jgeddes_4-1707839362526.png

Add a column that determines which table's value we will end up with.

jgeddes_5-1707839412948.png

Now select the 'exceptionValue' column and choose 'Replace Values' from the 'Transform' ribbon...
Use 'null' as the value to find and a random number as the 'Replace With' value. It does not matter what number as we are changing it right away.

jgeddes_6-1707839572076.png

The function value should populate with...

jgeddes_8-1707839650553.png

Replace the '99999' with 'each [masterValue] and you should end up with...

jgeddes_9-1707839715242.png

You can now change remove the masterValue column if you do not need it for other purposes, change data types and rename columns as desired to end up with...

jgeddes_10-1707839799392.png

Hope this helps.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





TDK
Frequent Visitor

Hi Febin,

So I would sugest the following (assuming you are using PBI Desktop):

  1. When inside the Power Query Editor under Transform Data - Go to and click on your Master Roster query and look on the ribbon at the top of the screen, under the Home tab to the right you shoul see Merge Queries click on that.
  2. From there you should be presented with a merge wizard, select the Roster Exception table from the dropdown and then on the preview tables CTRL+click on the colums employeeid and Schedule date you want to join on. You will notice it highlights the column and there should be a small number next to the column name. The order here is important. Then check if the join is set to Left Join. Click ok
  3. After a bit of time you should now see a table with an additional column with the word "table" in bold. Next to the column you should see a icon that looks like 2 arrows pointing away from eachother, click on that and this should enable you to expand the data from the joined table. Note! if there is more than one row from the Roster Exception that matches Master Roster you will create duplicate records in your Master Roster.
  4. Select the columns you care about and expand them, you should see nulls where you did not have any matches.
  5. You can then create a custom column, on the ribbon under the Add Column tab select Custom Column. Give the column a name like Exception Flag and then in the formula bar type:
    <column name> = null
    Where <column name> is the coumn you are checking for nulls, this will generate a True or False that you can use as your flag

That should be it.

Hope it helps

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors