Forum Discussion
MichielS340
Jul 25, 2024Brass Contributor
Excel combine lambda and countif in formula
Hi, I have the following formula to get a range of values (col) of which i want to check how many times the values appear in the range and then filter for more than one time (duplicates). Someho...
djclements
Jul 25, 2024Silver Contributor
MichielS340 COUNTIF does not work with an array object in the range argument. You could try replacing COUNTIF(col;r) with SUM(N(col=r))>1. For example:
=LET(
tbl; UNIQUE(VSTACK(HSTACK(tbl_Prognose[PRJ_NR];tbl_Prognose[DESC]);HSTACK(tbl_Orderportefeuille[Nummer];tbl_Orderportefeuille[Omschrijving])));
col; CHOOSECOLS(tbl;1);
FILTER(tbl;MAP(col;LAMBDA(r;SUM(N(col=r))>1));"")
)
An alternative approach without BYROW or MAP could be:
=LET(
tbl; UNIQUE(VSTACK(HSTACK(tbl_Prognose[PRJ_NR];tbl_Prognose[DESC]);HSTACK(tbl_Orderportefeuille[Nummer];tbl_Orderportefeuille[Omschrijving])));
col; CHOOSECOLS(tbl;1);
only_once; UNIQUE(col;;1);
FILTER(tbl;ISERROR(XMATCH(col;only_once));"")
)
See attached...
MichielS115
Jul 25, 2024Copper Contributor
Very elegang, many thanks for your help!