Forum Discussion
TP700
Mar 13, 2024Copper Contributor
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
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)) ) ) )
- PeterBartholomew1Silver Contributor
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)
So far I don't use these two aggregation functions due to compatibly. Played a bit and keep for the future.
- PeterBartholomew1Silver ContributorA concrete example with the expected result (hand calculated) would be useful.
- TP700Copper 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
- PeterBartholomew1Silver Contributor
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.