Forum Discussion

NhatLinh_2012's avatar
NhatLinh_2012
Copper Contributor
Jun 28, 2024

Count value in column

Can you help me with this issue ?

I want to count the number of anime grouped by genres but I have 6 columns of genres. In output, I want to have a column for unique genre and a column for number of anime.

How can I do that?

 

3 Replies

  • pakkijobs's avatar
    pakkijobs
    Copper Contributor

    You have an Excel table with 6 columns for genres, and you want to count how many times each unique genre appears across all columns. The output should look like:

     

    Genre    Count
    Action    45
    Romance    30
    Comedy    25


    Solution in Excel
    Combine all genre columns into one column
    Suppose your genres are in columns B:G.
    Copy all 6 columns and paste them below each other into a single helper column (say column H).
    Now you have one long list of all genres.
    Remove blanks (if any).
    Insert PivotTable
    Select the helper column (H).
    Go to Insert → PivotTable.
    Drag Genre into Rows.
    Drag Genre again into Values → change to Count.
    ✅ This will give you a unique list of genres with their counts.
    ⚡ Formula Alternative (without PivotTable)

    If your data is in B2:G100:

    Put this formula in H2 (spill formula for Excel 365+):→ Joins all 6 genres into one cell separated by commas.

    =TEXTJOIN(",",TRUE,B2:G2)


    Then use Power Query or split the joined data into rows (Data → Split Column → By Delimiter → Expand rows).
    Finally, count genres with PivotTable or COUNTIF.

  • olafhelper's avatar
    olafhelper
    Bronze Contributor

     


    but I have 6 columns of genres.

    NhatLinh_2012 , sounds like bad database design and that causes always problems in analytics.

    The screenshot is much to small to see anything.

    Please post table design as DDL, some sample data as DML statement and the expected result. 

  • Arshad440's avatar
    Arshad440
    Brass Contributor
    That's less on information.please provide DDL for better Understanding

    Regards

Resources