+ Reply to Thread
Results 1 to 6 of 6

Count unique text strings in a column

Hybrid View

Darren Waters Count unique text strings in... 12-05-2023, 10:35 AM
Fluff13 Re: Count unique text strings... 12-05-2023, 10:46 AM
Darren Waters Re: Count unique text strings... 12-05-2023, 10:52 AM
Fluff13 Re: Count unique text strings... 12-05-2023, 10:59 AM
HansDouwe Re: Count unique text strings... 12-05-2023, 11:00 AM
Czeslaw Re: Count unique text strings... 12-06-2023, 05:50 AM
  1. #1
    Registered User
    Join Date
    12-05-2023
    Location
    Cardiff
    MS-Off Ver
    Version 16.79.2 MAC
    Posts
    4

    Question Count unique text strings in a column

    I'd appreciate some help.

    I have a column of tags. Each cell can have multiple tags separated by commas. Each cell will have a unique set of tags within that cell, but tags can be repeated in other rows.

    e.g.
    Dog, Duck, Barn, Door
    Dog, Cat, Cow
    Door, Sheep, Goat
    Barn, Farmer, Dog

    How do I list out the unique tags only and then count how many of those unique tags are in the column?

    Ideally what I'd like is the unique tags listed in one column with the count in the next column. e.g.

    Dog 3
    Duck 1
    Barn 2
    Door 2
    Cat 1
    Cow 1
    Sheep 1
    Goat 1
    Farmer 1

    thanks
    Last edited by Darren Waters; 12-05-2023 at 10:53 AM. Reason: Solved

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,792

    Re: Count unique text strings in a column

    How about
    Formula: copy to clipboard
    =LET(a,TRIM(TEXTSPLIT(TEXTJOIN(", ",,A2:A5),,",")),u,UNIQUE(a),HSTACK(u,BYROW(u,LAMBDA(br,SUM(--(br=a))))))

  3. #3
    Registered User
    Join Date
    12-05-2023
    Location
    Cardiff
    MS-Off Ver
    Version 16.79.2 MAC
    Posts
    4

    Re: Count unique text strings in a column

    Wow. Thank you Fluff13. That's amazing. Could I ask one more favour - would you mind walking through the formula and what the parts do? I'd massively appreciate that.

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,792

    Re: Count unique text strings in a column

    The textjoin joins all the rows with a comma in between & the textsplit then splits everything into a vertical array based on the commas.
    The hstack then stacks the unique values in one column with the count in the other.

  5. #5
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Count unique text strings in a column

    Please try:
    Formula: copy to clipboard
    =LET(t,TEXTSPLIT(TEXTJOIN(", ",,A1:A4),,", "),u,UNIQUE(t),HSTACK(u,MAP(u,LAMBDA(c,SUM(N(c=t))))))
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,420

    Re: Count unique text strings in a column

    Power Query
    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        #"Split Column by Delimiter" = Table.SplitColumn(Source,"Column1",Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv),{"Column1.1", "Column1.2", "Column1.3", "Column1.4"}),
        #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Split Column by Delimiter", {}, "Attribute", "Value"),
        #"Trimmed Text" = Table.TransformColumns(#"Unpivoted Columns",{{"Value", Text.Trim}}),
        #"Grouped Rows" = Table.Group(#"Trimmed Text", {"Value"}, {{"Count", each Table.RowCount(_), type number}})
    in
        #"Grouped Rows"
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Count Unique (Long) Strings
    By eNinjaInTraining in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-15-2021, 10:23 PM
  2. [SOLVED] Using a Referencing a Column to Count 2 different text strings in another Column
    By marshallmr in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-05-2019, 02:02 PM
  3. Replies: 20
    Last Post: 08-24-2017, 02:40 AM
  4. [SOLVED] Need count of unique text values in column
    By kitpierce in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-21-2017, 01:01 PM
  5. [SOLVED] count text strings in column but ignore duplicates & blanks
    By y_not in forum Excel General
    Replies: 4
    Last Post: 06-28-2015, 11:57 AM
  6. How do I count the # of unique occurences of a text in a column?
    By Rob Kaiser in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-14-2005, 02:05 AM
  7. [SOLVED] Count Unique Strings
    By stacy_jeanne@yahoo.com in forum Excel General
    Replies: 4
    Last Post: 04-27-2005, 03:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1