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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Morgana_2022
Helper I
Helper I

Counting values

How do I count some values within a field?

Ex. I have the "Fruit" field, made up of the values:
Banana
Banana
Strawberry
Kiwi

I have to get:
Banana = 2
Strawberry = 1
Kiwi = 1

My formula, butit does not work:

Fruit type = Sum ('fruit'[total]) - Sum ('fruit'[type] = "Banana")
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Morgana_2022 

You can through ALLEXCEPT() to count values in groups .

 

Measure = calculate(COUNT('Table'[Fruit]),ALLEXCEPT('Table','Table'[Fruit]))

 

The result is as shown :

Ailsamsft_0-1658825523137.png

Best Regards,
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Morgana_2022 

You can through ALLEXCEPT() to count values in groups .

 

Measure = calculate(COUNT('Table'[Fruit]),ALLEXCEPT('Table','Table'[Fruit]))

 

The result is as shown :

Ailsamsft_0-1658825523137.png

Best Regards,
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

serpiva64
Solution Sage
Solution Sage

Hi,

you can use a mesaure:

Measure = count(Fruit[Fruit])
or without a mesaure you can use aggregation:
serpiva64_0-1658499947309.png

 

If this post is useful to help you to solve your issue, consider giving the post a thumbs up and accepting it as a solution !

 

 

Hi,
thanks! But how can I make a measure with the strawberry count alone?

ex.
Count ('Fruit' [Type] = "Strawberry")

Hi,

This is the measure 

Measure2 = Calculate(count(Fruit[Fruit]),Fruit[Fruit]="Strawberry")
or
Measure3 = if(isfiltered(Fruit[Fruit]),sumX(Fruit, if(Fruit[Fruit]="Strawberry", count(Fruit[Fruit]),0)))

but it depends what you need to do with it.

If you use them in a table you obtain

 

serpiva64_1-1658502912545.png

 

 

If this post is useful to help you to solve your issue, consider giving the post a thumbs up and accepting it as a solution !

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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