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
Mahi1989
Frequent Visitor

Compare a value from two column and get matching value from another table Power BI

Hi All

 

As i am fairly new to powerbi need your help in one task on which i am stuck on.

basically i have two tables and i need to compare the value from table one with a row of table 2 and return the output.

Table 1

Table1.JPG

 

 I need to compare values in column a & b and get a match from table 2. for example if row 1 has BY Green & BS HIGH. i need to check this value from matrix table below and return the output in column value as either 0 or 1

Table2.JPG

 

so if you see Table2 first row has value BY Green and BS low has a value '0'

 

Regards

Mahi1989

 

 

 

2 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

 

In the Query Editor, right click on the first column in Table2 and select "Unpivot other columns".  This will convert that Table into a 3 column one.  In the Query Editor itself, merge the two tables by connecting the first two columns of Table1 with the first two columns of Table2.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

Hi,

 

Once you bring over the Value column from Table2 to Table1, write this calculated column formula in Table1

 

=if [Column A] ="BY Green" and [Column B]="BS High" and [Value]>=5 then 1 else 0

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

 

In the Query Editor, right click on the first column in Table2 and select "Unpivot other columns".  This will convert that Table into a 3 column one.  In the Query Editor itself, merge the two tables by connecting the first two columns of Table1 with the first two columns of Table2.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish.. Thanks for suggesting the solution. This really worked. But there has been a constraint added to original problem. basically a new column "Time" in table 1 before value column and we have values in time column which needs to be taken into consideration also. say we have two below rows

 

 

Col ACol BTimeValue
    
BY GreenBS High10
    
BY GreenBS High51
    
BY RedBS Low10

 

 

the ask is for few combinations not all we have to take time value also in consideration. lets say combination BY Green BSHigh as per table two value this is illegal. but if time value is >=5 for this then the value becomes legal. Please bear in mind that this condition is not for all combinations only for few of them.

 

Regards Mahi1989

Hi,

 

Once you bring over the Value column from Table2 to Table1, write this calculated column formula in Table1

 

=if [Column A] ="BY Green" and [Column B]="BS High" and [Value]>=5 then 1 else 0

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.