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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Dynamic Running Count based on Year

Hi guys,

 

I have the challenge below of running count based on filter

 

for example: I need to build the measure COUNT to count the codes as below:

 

CODEYEARCOUNT
A20191
B20192
C20203
D20224
E20225
F20226
G20227
H20228

 

Then if Year is selected in the filter I need to run that count over again from 1

 

FILTER YEAR: 2022

 

CODEYEARCOUNT
D20221
E20222
F20223
G20224
H20225

 

is that possible?

 

Thanks in advance

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1665643540575.png

 

Count measure: =
IF (
    HASONEVALUE ( Data[CODE] ),
    COUNTROWS ( FILTER ( ALLSELECTED ( Data ), Data[CODE] <= MAX ( Data[CODE] ) ) )
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Thanks for getting back to me

I forgot to mention one point, what if I have duplicated codes?

 

Thanks!

Hi,

Please share your revised dataset and show the expected result clearly.


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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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