Excel Formula to find Unique values from Data Table

b bb 6 Reputation points
2021-07-22T16:45:05.573+00:00

Thank you for taking the time to read my question.

I have a data table with many customers. Each customer has many sites. I'm wondering if it's possible to use Excel formulas to return the unique list of sites based on the Customer name entered into a cell. Next I'd like to be able to show the unique values horizontally.

Is this possible or do I need to write a quick macro?

Data Table:

Customer 1 Site 1 Other data
Customer 1 Site 1 Other data
Customer 1 Site 1 Other data
Customer 1 Site 1 Other data
Customer 1 Site 1 Other data
Customer 1 Site 2 Other data
Customer 1 Site 2 Other data
Customer 1 Site 2 Other data
Customer 1 Site 2 Other data
Customer 1 Site 3 Other data
Customer 2 Site A Other data
Customer 2 Site A Other data
Customer 2 Site B Other data
Customer 2 Site B Other data

User Input: Customer 1

Result I'd like to see

    A           B         C

1| Site 1 | Site 2 | Site 3

I found the Unique() function but I need to pass it a range of cells and I'm not sure how to do that. I also found the Transpose() function which I thought I could put the Unique() function in.

=Transpose(Unique("The range I'm not sure how to pass",True,True))

Thanks

Microsoft 365 and Office | Excel | For business | Windows
{count} votes

3 answers

Sort by: Most helpful
  1. Viki Ji_MSFT 4,471 Reputation points
    2021-07-23T07:55:30.77+00:00

    @b bb ,
    Welcome to Q&A forum!

    Please check whether the following formula is helpful to you, since it is an array formula, please press Ctrl+Shift+Enter to check after typing.
    For more information about INDEX: INDEX function.

    =IFERROR(INDEX($B$2:$B$15,MATCH(0,IF($D2=$A$2:$A$15,COUNTIF($D2:D2,$B$2:$B$15),""),0)),"")  
    

    117344-image.png

    Any updates, please let me know.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Ashish Mathur 100.8K Reputation points Volunteer Moderator
    2025-07-23T06:17:34.46+00:00

    Hi,

    In cell D2, enter this formula

    =UNIQUE(A2:A15)

    In cell E2, enter this formula

    =IFERROR(DROP(REDUCE("",D2#,LAMBDA(a,b,VSTACK(a,TOROW(UNIQUE(FILTER(B2:B15,A2:A15=b)))))),1),"")

    Hope this helps.

    User's image

    0 comments No comments

  3. Ashish Mathur 100.8K Reputation points Volunteer Moderator
    2025-07-23T06:23:33.6533333+00:00

    Hi,

    This Power Query code works as well

    let
        Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
        #"Removed Duplicates" = Table.Distinct(Source),
        #"Grouped Rows" = Table.Group(#"Removed Duplicates", {"Customer"}, {{"Count", each Table.AddIndexColumn(_,"Index",1)}}),
        #"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"Site", "Index"}, {"Site", "Index"}),
        #"Added Prefix" = Table.TransformColumns(#"Expanded Count", {{"Index", each "Col " & Text.From(_, "en-IN"), type text}}),
        #"Pivoted Column" = Table.Pivot(#"Added Prefix", List.Distinct(#"Added Prefix"[Index]), "Index", "Site")
    in
        #"Pivoted Column"
    

    User's image

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.