Forum Discussion

TP700's avatar
TP700
Copper Contributor
Mar 13, 2024

Checking for criteria in whole column

Hello, I am trying to get a formula that will lookup a criteria in one column and then return value in another column if that too matches a second criteria. How do I do this? Thanks

  • TP700 

    Depends on in which form you'd like to have the result. As variant

    with

    =LET(
        types, TOROW(SORT(UNIQUE(type))),
        codes, SORT(UNIQUE(code)),
        VSTACK(
            HSTACK("",types),
            HSTACK(codes,
                MMULT(--(TRANSPOSE(TOROW(codes)=code)),
                      --(type=types))
            )
        )
    )
    • PeterBartholomew1's avatar
      PeterBartholomew1
      Silver Contributor

      SergeiBaklan 

      Agreed, there are better layouts.  To be told in triplicate that there are three occurrences would seem to be excessive.  Mind you, your skills are soon to be overtaken by

      = PIVOTBY(uniqueCode, type, type, COUNTA, ,0, ,0)

       

    • TP700's avatar
      TP700
      Copper Contributor

      Hi Peter, I can't send my actual working file as it contains sensitive data, so I've put more information into my example file to show what I mean. Thanks

      • PeterBartholomew1's avatar
        PeterBartholomew1
        Silver Contributor

        TP700 

        A formula you might care to try is

        = COUNTIFS(uniqueCode, uniqueCode, type, "Type1")

        where, hopefully, the defined names are obvious.  With 365 the formula should spill to the entire column.

Resources