SOLVED

Question releated to Match function

%3CLINGO-SUB%20id%3D%22lingo-sub-2743163%22%20slang%3D%22en-US%22%3EQuestion%20releated%20to%20Match%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2743163%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Everyone%2C%3C%2FP%3E%3CP%3EIn%20below%20screenshot%2C%20I%20am%20using%20the%20MATCH%20FUNCTION%20but%20apples%2C%20position%20shows%201%3C%2FP%3E%3CP%3Elike%20-%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screenshot%20(4878).png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F309837iFF76362AEE5A103E%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Screenshot%20(4878).png%22%20alt%3D%22Screenshot%20(4878).png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20to%20show%20apple's%20position%20%3CSTRONG%3E1%2C%205%2C%207%26nbsp%3B%3C%2FSTRONG%3E(in%20comma%20seperated)%20with%20the%20help%20of%20MATCH%20FUNCTION%3C%2FP%3E%3CP%3ESo%2C%20what%20formula%20should%20i%20write%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20using%20Microsoft%20Office%202019%20Home%20and%20student.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20help..%3F%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20a%20attached%20file..%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2743163%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2743176%22%20slang%3D%22en-US%22%3ERe%3A%20Question%20releated%20to%20Match%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2743176%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F811137%22%20target%3D%22_blank%22%3E%40Zan_Hanifee%3C%2FA%3E%26nbsp%3BMATCH%20isn't%20suitable%20for%20this%2C%20I'm%20afraid.%20Given%20your%20Excel%20version%20this%20might%20work%20though%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DTEXTJOIN(%22%2C%22%2CTRUE%2CIFERROR(1%2F(%24A%242%3A%24A%248%3DD4)*(ROW(%24A%242%3A%24A%248)-1)%2C%22%22))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EPerhaps%20you%20need%20to%20enter%20the%20the%20formula%20with%20Ctrl-Shift-Enter%20(CSE)%20on%20your%20version.%20Not%20sure.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFile%20attached.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2743214%22%20slang%3D%22en-US%22%3ERe%3A%20Question%20releated%20to%20Match%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2743214%22%20slang%3D%22en-US%22%3ESir%2C%20Why%20we%20divide%20by%201%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2743245%22%20slang%3D%22en-US%22%3ERe%3A%20Question%20releated%20to%20Match%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2743245%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F811137%22%20target%3D%22_blank%22%3E%40Zan_Hanifee%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDividing%20into%201%20generates%20errors%20for%20each%20mismatch%20which%20are%20then%20trapped%20and%20turned%20into%20blanks.%26nbsp%3B%20An%20alternative%20would%20be%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3D%20TEXTJOIN(%22%2C%22%2C%20TRUE%2C%20IF(fruit%3D%22apple%22%2C%20ROW(fruit)-1%2C%22%22))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EExcel%20365%20can%20look%20very%20different%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3D%20LET(%0A%20%20n%2C%20COUNTA(fruit)%2C%0A%20%20k%2C%20SEQUENCE(n)%2C%0A%20%20f%2C%20FILTER(k%2C%20fruit%3D%22apple%22)%2C%0A%20%20TEXTJOIN(%22%2C%22%2C%2Cf))%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2743256%22%20slang%3D%22en-US%22%3ERe%3A%20Question%20releated%20to%20Match%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2743256%22%20slang%3D%22en-US%22%3EThank%20you%20so%20much%20sir.%3C%2FLINGO-BODY%3E
Regular Contributor

Hello Everyone,

In below screenshot, I am using the MATCH FUNCTION but apples, position shows 1

like - 

Screenshot (4878).png

 

I want to show apple's position 1, 5, 7 (in comma seperated) with the help of MATCH FUNCTION

So, what formula should i write?

 

I am using Microsoft Office 2019 Home and student.

 

Please help..??

 

Here is a attached file..

 

7 Replies
best response confirmed by Zan_Hanifee (Regular Contributor)
Solution

@Zan_Hanifee MATCH isn't suitable for this, I'm afraid. Given your Excel version this might work though:

=TEXTJOIN(",",TRUE,IFERROR(1/($A$2:$A$8=D4)*(ROW($A$2:$A$8)-1),""))

Perhaps you need to enter the the formula with Ctrl-Shift-Enter (CSE) on your version. Not sure.

 

File attached.

Sir, Why we divide by 1?

@Zan_Hanifee 

Dividing into 1 generates errors for each mismatch which are then trapped and turned into blanks.  An alternative would be

= TEXTJOIN(",", TRUE, IF(fruit="apple", ROW(fruit)-1,""))

Excel 365 can look very different

= LET(
  n, COUNTA(fruit),
  k, SEQUENCE(n),
  f, FILTER(k, fruit="apple"),
  TEXTJOIN(",",,f))
Thank you so much sir.
Comparison type can be -1, 0, or 1. 1 searches for the largest value that is less than or equal to the search criterion.
Zero (0) searches for the first value that exactly matches the value search criterion. -1 searches for the smallest value that is greater than or equal to the search criterion.

Hope I was able to help you with this info.

Nikolino
I know I don't know anything (Socrates)
Thank you so much sir

@Zan_Hanifee 

I am not suggesting that anyone should do this; it is simply an exercise in the application of new methods under development within Excel 365.

= LAMBDA(lookup_value,lookup_array,
    LET(
      k, SEQUENCE(ROWS(lookup_array)),
      AMATCHλ, LAMBDA(acc,k,
        IF(INDEX(lookup_array,k)=lookup_value,
           IF(LEN(acc), acc&","&k, k),
           acc)),
    REDUCE("", k, AMATCHλ))
  )("apple", fruit)

Within the LET it defines the named sequence 'k' and a function that will append a single value from 'k' to 'acc' if the corresponding fruit matches the lookup value.  REDUCE then runs through each 'k' in turn.  The formula works as it is, but, if the enclosing Lambda function is named 'MULTIMATCHλ', it may be reused anywhere within the workbook, e.g.

= MULTIMATCHλ(UNIQUE(fruit), fruit)

will return any array of results corresponding to each fruit category.  A minor plus for the approach is that SEQUENCE is robust to the insertion of rows, whereas ROW is necessarily fragile.