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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
SG-01
Helper I
Helper I

Count repeating values

Hi, I have for example the following data:

ProductValues
120
120
215
310
15

I want to count how many times the value 20 returns in a row. So, for this case it will be two. How can I calculate that in DAX?

1 ACCEPTED SOLUTION

Hi @SG-01 ,

 

There should be a column that indicates which row comes before which. To do that, add an Index column in Power Query then create a calculation to identify whether a value in the current row is the same as the next row and vice versa. If what you are looking for is as below, the solution is in the attached pbix.

 

danextian_0-1689139192548.png

danextian_0-1689139192548.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

5 REPLIES 5
danextian
Super User
Super User

Hi @SG-01 ,

 

This depends on how you want the result to be shown in a visual. For 20 alone,

=
CALCULATE ( COUNTROWS ( 'table' ), FILTER ( 'table', 'table'[Values] = 20 ) )
=
CALCULATE ( COUNTROWS ( 'table' ), 'table'[Values] = 20 )

For every unique value (can either bve a calc column or a measure, use calc column if you want to be able to use the count in a slicer)

=
CALCULATE ( COUNTROWS ( 'table' ), ALLEXCEPT ( 'table', 'table'[Values] ) )

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian I think I was not clear enough. I want to count the repeating values. So if the value occurs several times in a row then they must be counted. Otherwise it is just 1. In the example is for product 1 the value 2 times in a row, so the count will be two. The other products are just 1.

Hi @SG-01 ,

 

There should be a column that indicates which row comes before which. To do that, add an Index column in Power Query then create a calculation to identify whether a value in the current row is the same as the next row and vice versa. If what you are looking for is as below, the solution is in the attached pbix.

 

danextian_0-1689139192548.png

danextian_0-1689139192548.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian Thanks a lot, this was what I needed!

@danextian I still have a question. In my data there is another index that should determine if it is a recurring value and that is a name. So when INDEX 1 and NAME 1 has the value 20 and then INDEX 2 and NAME 1 has the value 20 then it is repeating. How can I accomplish this?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors