Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Trying to count the number of times a value from one column appears while filtered a certain way

Data looks like this:

 

 

Column A           Column B

asdf                     no

adsf                     yes

adsf                     no

czcz                     yes

czcz                     yes

 

I want to count the "yes" values and i want to add a calculated column (Column C) that looks like this below where the # of yes's for a given value in column A is shown for all of those values if it repeats:

 

Column A        Column C

asdf                     1

adsf                     1

adsf                     1

czcz                     2

czcz                     2

 

Thanks in advance...

2 ACCEPTED SOLUTIONS
mahoneypat
Employee
Employee

Please try this column expression, replacing Table with your actual table name.

 

Yes Count =
CALCULATE (
    COUNT ( Table[ColumnA] ),
    ALLEXCEPT (
        Table,
        Table[ColumnA]
    ),
    Table[ColumnB] = "yes"
)

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

Try his calculated column formula

=CALCULATE(CALCULATE(COUNTROWS(Data),Data[Reply]="yes"),FILTER(Data,Data[Text]=EARLIER(Data[Text])))

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Try his calculated column formula

=CALCULATE(CALCULATE(COUNTROWS(Data),Data[Reply]="yes"),FILTER(Data,Data[Text]=EARLIER(Data[Text])))

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
mahoneypat
Employee
Employee

Please try this column expression, replacing Table with your actual table name.

 

Yes Count =
CALCULATE (
    COUNT ( Table[ColumnA] ),
    ALLEXCEPT (
        Table,
        Table[ColumnA]
    ),
    Table[ColumnB] = "yes"
)

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.