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
totoalbin
Helper I
Helper I

Merge Two Tables based on Qualification

Hello,

 

I have two tables.  Table 1 shows the School and the different Standards they have.  Table 2 shows the teachers and their qualifications based on the three Standards.  Table 3 shows the possible lists of teachers that can be accepted based on the three standards.  Example School A had 7 possible Teachers wherein it doesn't have any Standard yet therefore all teachers can apply in School A.   In School B had only Nadia since she's the only one who has passed Standard 1 and Standard 3.   How can I ahieve this list in PowerBI?

 

Table 1. Student

 

School

Standard1

Standard2

Standard3

A

0

0

0

B

1

0

1

C

0

1

0

D

1

1

1

E

1

1

0

 

 Table 2. Teacher

 

Teacher Name

Standard1

Standard2

Standard3

Gretchen

0

1

1

Nadia

1

1

1

Inca

0

1

0

Michelle

0

0

1

Melina

1

0

0

Gail

0

1

1

Tessa

1

1

0

 

 

Table 3. Qualified

 

School

Teacher

A

Gretchen

A

Nadia

A

Inca

A

Michelle

A

Melina

A

Gail

A

Tessa

B

Nadia

C

Gretchen

C

Nadia

C

Inca

D

Nadia

E

Tessa

E

Nadia

 

 

Thank you very much,

 

Alvin

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

first make the names of the Standards in both tables distinct, like S_S1, S_S2, and S_S3 for the Standards in the school table and T_S1 ... in the teachers table

Assuming that your tables are called School and Teacher ...

 

In PowerQuery (meaning no DAX) add a new custom column to the school table like so:

image.png

 

Basically this will create a cartesian product of both tables ...

Expand the table "Teacher"
image.png

Now create 3 custom columns called Q_S1, Q_S2_, and Q_S3 (Q means qualifies), here is the formula for Q_S1:

if [S_S1] = 0 then 1 else if [T_S1] = 1 then 1 else 0


This creates the value 1 if both columns (School and Teacher) have a value of 1 or the school value is 0, otherwise the formula returns 0. 

Adjust the column references for the columns Q_S2 and Q_S3 accordingly.

 

Create another custom column and call it "Qualified" or something similar and use this formula:

if [Q_S1] + [Q_S2] + [Q_S3] = 3 then "qualified" else "not qualified"

Now you have a "School" table that also contains the "Teacher" content and a column called "Qualified" that you can use to filter.

 

Hopefully this gives you an idea.

 

Regards,
Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

5 REPLIES 5
TomMartens
Super User
Super User

Hey,

 

first make the names of the Standards in both tables distinct, like S_S1, S_S2, and S_S3 for the Standards in the school table and T_S1 ... in the teachers table

Assuming that your tables are called School and Teacher ...

 

In PowerQuery (meaning no DAX) add a new custom column to the school table like so:

image.png

 

Basically this will create a cartesian product of both tables ...

Expand the table "Teacher"
image.png

Now create 3 custom columns called Q_S1, Q_S2_, and Q_S3 (Q means qualifies), here is the formula for Q_S1:

if [S_S1] = 0 then 1 else if [T_S1] = 1 then 1 else 0


This creates the value 1 if both columns (School and Teacher) have a value of 1 or the school value is 0, otherwise the formula returns 0. 

Adjust the column references for the columns Q_S2 and Q_S3 accordingly.

 

Create another custom column and call it "Qualified" or something similar and use this formula:

if [Q_S1] + [Q_S2] + [Q_S3] = 3 then "qualified" else "not qualified"

Now you have a "School" table that also contains the "Teacher" content and a column called "Qualified" that you can use to filter.

 

Hopefully this gives you an idea.

 

Regards,
Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thank you very much it works!

Thank you very much havent tried this yet but I will once I get back.
Greg_Deckler
Super User
Super User

Can you post that data as something that can be copied and pasted? Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I apologize for this.  Will correct it.

 

Thank you very much

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.