Search code examples
excelexcel-formula

How to consume data of 1 column based on other column


I have a sheet with 4k records and need to consume data before importing to the system and face a problem with Excel formula since I'm not familiar with it.

How can I consume data from Dosage column (B) based on Medicine column (A), my expected result should be like G or H (any of Result 1 or 2 is fine).

enter image description here


Solution

  • GROUPBY() is perfect function for this case.

    =GROUPBY(A1:A15,B1:B15,LAMBDA(x,ARRAYTOTEXT(UNIQUE(x))),3,0)
    

    If you do not have access to GROUPBY() then try-

    =HSTACK(UNIQUE(A2:A15),MAP(UNIQUE(A2:A15),
    LAMBDA(x,TEXTJOIN(", ",1,UNIQUE(FILTER(B2:B15,A2:A15=x))))))
    

    enter image description here