Forum Discussion

rangelsammon's avatar
rangelsammon
Brass Contributor
Dec 18, 2022
Solved

Unique range with space in between

https://1drv.ms/x/s!AnFi6uGE1rekjWMiExJCd5UPyZEq?e=QkobYl

 

at the moment using a IF formula to display a list of unique values from another list but wondering if a cleaner way of doing with using an array to show using # or something similar.

 

i  have       and  i want

1                          1

1

2                           2

2

 

so not to have the same number appear below. only to have the number appear below with the spaces in between. i hope this makes sense. see sheet attached. thank you!

  • rangelsammon 

     

    Alternatively, assuming the same serie doesn't repeat in A2:A15, in B2:

     

     

    =IF(DROP(FREQUENCY(A2:A15,A2:A15),-1),A2:A15,"")

    or

    =IF(XMATCH(A2:A15,A2:A15)=SEQUENCE(ROWS(A2:A15)),A2:A15,"")

     

     

     

8 Replies

  • rangelsammon's avatar
    rangelsammon
    Brass Contributor
    thank you so much for the responses! is there a way to do this using a2# vs a2:a15
    • Lorenzo's avatar
      Lorenzo
      Silver Contributor
      If A2:A15 is actually a dynamic array, replace A2:A15 with A2# in the various proposal you got, that should work...
  • Patrick2788's avatar
    Patrick2788
    Silver Contributor

    rangelsammon 

    I like going with REDUCE for this task:

    =REDUCE("After",UNIQUE(data),SStack)

    Though, I prefer to use EXPAND within 'SStack (Selective Stack):

    =LAMBDA(a,v,LET(k, COUNT(FILTER(data, data = v)), VSTACK(a, EXPAND(v, k, 1, ""))))

     

  • brunomerola's avatar
    brunomerola
    Brass Contributor

    rangelsammon 

     

    This should work fine:

    =LET(
       data,$A$2:$A$15,
       posUnique,XMATCH(UNIQUE(data),data), 
       MAP(SEQUENCE(ROWS(data)),LAMBDA(n,IF(ISNUMBER(XMATCH(n,posUnique)),INDEX(data,n),""))))

     

  • Lorenzo's avatar
    Lorenzo
    Silver Contributor

    rangelsammon 

     

    Alternatively, assuming the same serie doesn't repeat in A2:A15, in B2:

     

     

    =IF(DROP(FREQUENCY(A2:A15,A2:A15),-1),A2:A15,"")

    or

    =IF(XMATCH(A2:A15,A2:A15)=SEQUENCE(ROWS(A2:A15)),A2:A15,"")

     

     

     

    • rangelsammon's avatar
      rangelsammon
      Brass Contributor
      i used the drop frequency but i love learning all of the new formula functions provided. thank you everyone!
      • Lorenzo's avatar
        Lorenzo
        Silver Contributor
        Glad we could help & Thanks for providing feedback
  • Harun24HR's avatar
    Harun24HR
    Bronze Contributor

    rangelsammon Try-

     

    =IF(A2:A15<>A1:A14,A2:A15,"")

     

    Better you can use REDUCE() function like-

     

    =DROP(REDUCE("",A2:A15,LAMBDA(a,x,VSTACK(a,IF(ISERROR(XMATCH(x,a,0)),x,"")))),1)

     

    To make input column more dynamic use A2:INDEX(A:A,COUNTA(A:A)) Try-

     

    =DROP(REDUCE("",A2:INDEX(A:A,COUNTA(A:A)),LAMBDA(a,x,VSTACK(a,IF(ISERROR(XMATCH(x,a,0)),x,"")))),1)

     

     

Resources