Forum Discussion

s4spencer's avatar
s4spencer
Regular Visitor
5 years ago
Solved

Group By Name Then Add Column With Count Of Each Group

Hi,

 

I'm trying to group together names and then get a count of each group, and add the count of the records group to itself (for every row). There's an example below.

I do specifically need it to be a calculated column, and not just filtered with a visual.

 

If I have the following Names

[Name]

A

A

A

B

B

C

 

I want to end up with

[Name] | [Count]

A | 3

A | 3

A | 3

B | 2

B | 2

C | 1

 

Where A is 3 because there's 3 A's, B is 2 and C is 1 for similar reasons.

Anything i've been able to find so far points towards a measure, however the measure changes based on page/visual filters, and requires multiple visuals to manipulate it the way i'm trying to.

 

Any idea's how I can get the desired result?

  • s4spencer ,

     

    Create a new column with:

     

    Count = CALCULATE(COUNT('Table'[[Name]]]), ALLEXCEPT('Table', 'Table'[[Name]]]))

     

     

3 Replies

  • camargos88's avatar
    camargos88
    Icon for Community Champion rankCommunity Champion

    s4spencer ,

     

    Create a new column with:

     

    Count = CALCULATE(COUNT('Table'[[Name]]]), ALLEXCEPT('Table', 'Table'[[Name]]]))

     

     

    • s4spencer's avatar
      s4spencer
      Regular Visitor

      No idea why I struggled with this so much, many thanks!

      • s4spencer's avatar
        s4spencer
        Regular Visitor

        Just as a note for anyone who has the same issue and is having "one of those days". Make sure to check that your visuals aren't "summarizing" your counts. Was so convinced I was doing something wrong before I never checked the obvious.