Forum Discussion

Katescott's avatar
Katescott
Copper Contributor
Mar 27, 2023

Missing numbers in a column of repeating numbers

I am trying to determine missing numbers in a range for multiple values. I have tried multiple ways to drill down to the missing numbers 1-50. The numbers in Column A, B, C are relative, I tried conc...
  • davidleal's avatar
    davidleal
    Mar 28, 2023

    Katescott Now it is more clear, you can use the following formula:

     

    =LET(A, A1:A9, B,B1:B9, check,SEQUENCE(3), ux,UNIQUE(A),
     missing,MAP(ux, LAMBDA(x, TEXTJOIN(",",,FILTER(check, 
     ISNA(XMATCH(check,FILTER(B,A=x))),"")))),
     FILTER(HSTACK(ux,missing),missing<>""))

     

    In this sample, we assume the missing values we want to check are in the range of 1-3. Here is the sample output. It returns the rows from the first column with missing values. If more than one is missing, it returns a list separated by a comma. Here is the output, you can adjust to your need in your real situation, adjusting the names: A, B, and check. The last FILTER call is to just show the column row values with missing values only.

    Here is the output:

    You can also use COUNTIFS as follows:

     

    =LET(A,A1:A9, B,B1:B9, ux,UNIQUE(A), seq,SEQUENCE(,3), 
     cnts,COUNTIFS(A,ux,B,seq), missing,BYROW(cnts,LAMBDA(x,
     TEXTJOIN(",",,FILTER(seq,x=0,"")))), 
     FILTER(HSTACK(ux,missing),missing<>""))

     

    In both cases you can use MAP or BYROW I just changed it for illustrative purposes. For this case, seq has to be a column-wise array.

     

    If you want the result the other way around, i.e. for each number the missing letters, adapting for example the COUNTIFS approach and considering a numeric range or 1-5:

     

    =LET(A,A1:A9, B,B1:B9, ux,UNIQUE(A), seq,SEQUENCE(,5),
     cnts,COUNTIFS(A,ux,B,seq), missing, TOCOL(BYCOL(cnts,LAMBDA(x,
     TEXTJOIN(",",,FILTER(ux,x=0,""))))),
     FILTER(HSTACK(TOCOL(seq),missing),missing<>""))

     

    Now we use BYCOL and transpose the information using TOCOL.

     

    I hope it helps,

     

Resources