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
Anonymous
Not applicable

If match index across the columns then Yes or no

Hi,

 

I am new to power BI and this is my first post. Could you please help me the below mentioned query.

 

I have two tables here, Table1 is Master Data, Table2 is my report data(output data). I want output in Table2 against Table1. If match the criteria from master data(Table1) to Table2 (report data) then return the status is "Yes" if not then return the staus is "No".

Please advise alternative ways to achive my result (Like a formula in power Bi or table relasionship etc..).

How can attached the file here could you please share the link.  

 

TABLE1.PNGTable2.PNG

 

ITEMIDAREA CODEQTYLANGUAGESALES CODESTATUSIDAREAQTYLANGUAGESALES CODE
123RAMBUTAN3100100ENEU01OKAY-----
123RAMBUTAN3100100ENUSOKAY-----
123RAMBUTAN3100100ENUKOKAY-----
123RAMBUTANWEST100ENUKERROR-ERROR---
123RAMBUTAN31001ENUKERROR--ERROR--
123RAMBUTAN3100 ENUKERROR-- --
123RAMBUTAN3100100 UKERROR---ERROR-
123RAMBUTAN3100100ENINDIA01ERROR----ERROR
123RAMBUTAN3100100EN ERROR---- 
234STAR FRUITWEST200ENINDIA01OKAY-----
234STAR FRUITNORTH100ENINDIA01OKAY-----
234STAR FRUITEAST43ENINDIA01OKAY-----
234STAR FRUITSOUTH56ENINDIA01OKAY-----
234STAR FRUITWEST78ENINDIA02OKAY-----
234STAR FRUITNORTH99ENINDIA02OKAY-----
234STAR FRUITEAST133ENINDIA02OKAY-----
234STAR FRUITSOUTH45ENINDIA02OKAY-----
56WATERMELON 100ENUKOKAY-----

 

FRUIT LISTAREA CODEQTYLANGUAGESALES CODE 1SALES CODE 2SALES CODE 3
RAMBUTAN31001ENEU01USUK
RAMBUTAN32001ENEU01USUK
RAMBUTAN33001ENEU01USUK
RAMBUTAN45001ENEU01USUK
RAMBUTAN89001ENEU01USUK
       
STAR FRUITWEST1ENINDIA01INDIA02NA
STAR FRUITNORTH1ENINDIA01INDIA02NA
STAR FRUITEAST1ENINDIA01INDIA02NA
STAR FRUITSOUTH1ENINDIA01INDIA02NA
       
BANANAKP11ENXX1  
BANANAPP11ENXX2  
       
APPLE4441ENBAN03  
       
ORANGE5551ENBAN03  
ORANGE5551ENBAN04  
ORANGE5551ENBAN05  
       
PLUM1231ENBAN03  
       
WATERMELON 1ENEU01USUK

 

 

11 REPLIES 11
mhossain
Solution Sage
Solution Sage

@Anonymous 

 

What are the columns you are relating in two tables? You can try 'Merge' option as well in the powerquery.

Anonymous
Not applicable

thanks for your reply. I can't use the merge query becuase of my sales code contaion one column but in my master data shett 3 columns. Please advise how can I merge the query in this case?

 

Anonymous
Not applicable

 

Hi,

 

I achived my result in excel using the sumporduct formula.

In G2=IF(AND(SUMPRODUCT((TABLE1!A$2:A$18=B2)*(TABLE1!B$2:B$18=C2))>0,IF(B2="Banana",D2=1,D2>1),SUMPRODUCT((TABLE1!B$2:B$18=C2)*(TABLE1!D$2:D$18=E2))>0,SUMPRODUCT((TABLE1!B$2:B$18=C2)*(TABLE1!E$2:G$18=F2))>0),"YES","NO")

How can I achive the sumproduct in power BI.

 

Attached the excel file for your reference.

https://www.dropbox.com/scl/fi/yzwky0n1gghp76nifphjj/POER-BI-DATA.xlsx?dl=0&rlkey=f0tm0awk7arxuohz3z...

 

amitchandak
Super User
Super User

@Anonymous , new column in Table 2

if(isblank(related(Table1[Col1])), "No", "Yes")

Anonymous
Not applicable

Hi,

Thanks for your quck reply.

It's not working. Attached the snapshot of the error. Could you please advise how can I attached the file in this forum.ERROR.PNG

@Anonymous , This can work a new column in Table 2, when Table 1 and Table 2 are related in 1 to M.

 

Try this , new column in table 2

if(isblank(countx(filter(Table1, Table1[key] = table2[Key]),Table1[Key])), "No", "Yes")

Anonymous
Not applicable

Hi,

 

Sorry still it's not working. I am new to Power BI. Could you able to share the file or advise how can I attached the file?

Exactly I am following the same step as you advised but still I got the error message. What mean by "Key" in your formula? Please refer the snapshot for your reference.

 

Error1.PNG

Anonymous
Not applicable

any advise please.

Hi @Anonymous ,

 

>>If match the criteria from master data(Table1) to Table2 (report data) then return the status is "Yes" if not then return the staus is "No".

 

Would you please explain more about logic of matching the criteria from master data(Table1) to Table2 (report data)? 

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

 

 

 

 

Anonymous
Not applicable

Hi,

Thanks for your reply and sorry I am not explain clarly.

 

This is Table 2 data base.

result-example(T2).PNG

 

Example for line item 5; (In Table 2 Data) The item is 126 the fruit list is "Avocado" with area code is "West" it's not matched to my master data Table 1 therfore the status is "NO".

The "Avocado" area code beglogs to only the following sales code (EU01,US,UK).

If any error while matching (Fruit list, area code, qty, language, saltes code) the two tables from Table 2 to Table 1 then retuen the error message according to the Header. The item 126 is the area code is error becuase the area code not matched to my master data Table 1.

 

Example for line item 2; (In Table 2 Data) The item is 123 the fruit list is "Avocado" with area code is "3100" it's matched to my master data Table 1 therfore the status is "YES". There is no error here therefore need a blanks according to the header.

 

Match criteria: Here the selection criteria in both tables "Fruit list, area code + area code" in ordr to compare or match the following columns in both tables "qty, language, saltes code".

In Table 2 columns from B to F need to be matched from Table 1 columns from A to G. If matched then the status is "YES" if not then the status is "NO".

 

Qty columns conditions; The qty columns shondn't be blanks or 0. it's always greater than 1 expect the Banana with area code "PP1 and "KP1" its always equal to 1.

Sales code conditions; The sales code columns shondn't be blanks or 0.

 

Watermelon;

WM.PNG

Note; Watermelon doesn't have a area code. Please refer the output snapshot.

 

 Could you please let me know if you need a more information also please advise how can share or attached the file?

Table 2(Output sheet);

Table2(output)PNG.PNG

ITEMFRUIT LISTAREA CODEQTYLANGUAGESALES CODESTATUSIDAREAQTYLANGUAGESALES CODE
123Avocado3100100ENEU01YES     
124Avocado3100100ENUSYES     
125Avocado3100100ENUKYES     
126AvocadoWEST100ENUKNO ERROR   
127Avocado31001ENUKNO  ERROR  
128Avocado3100 ENUKNO  ERROR  
129Avocado3100100 UKNO   ERROR 
130Avocado3100100ENINDIA01NO    ERROR
131Avocado3100100EN NO    ERROR
234Star FruitWEST200ENINDIA01YES     
235Star FruitNORTH100ENINDIA01YES     
236Star FruitEAST43ENINDIA01YES     
237Star FruitSOUTH56ENINDIA01YES     
238Star FruitWEST78ENINDIA02YES     
239Star FruitNORTH99ENINDIA02YES     
240Star FruitEAST133ENINDIA02YES     
241Star FruitSOUTH45ENINDIA02YES     
56Watermelon 100ENUKYES     

 

Table 1(Master Data);

Table 1(MD).PNG

 

FRUIT LISTAREA CODEQTYLANGUAGESALES CODE 1SALES CODE 2SALES CODE 3
Avocado31001ENEU01USUK
Avocado32001ENEU01USUK
Avocado33001ENEU01USUK
Avocado45001ENEU01USUK
Avocado89001ENEU01USUK
Star FruitWEST1ENINDIA01INDIA02NA
Star FruitNORTH1ENINDIA01INDIA02NA
Star FruitEAST1ENINDIA01INDIA02NA
Star FruitSOUTH1ENINDIA01INDIA02NA
BananaKP11ENXX1NANA
BananaPP11ENXX2NANA
Apple4441ENBAN03NANA
Orange5551ENBAN03NANA
Orange5551ENBAN04NANA
Orange5551ENBAN05NANA
Plum1231ENBAN03NANA
Watermelon 1ENEU01USUK

 

Anonymous
Not applicable

Hi,

 

Could you please advise anyone or shall I close the thread.

 

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.