Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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:
| CODE | YEAR | COUNT |
| A | 2019 | 1 |
| B | 2019 | 2 |
| C | 2020 | 3 |
| D | 2022 | 4 |
| E | 2022 | 5 |
| F | 2022 | 6 |
| G | 2022 | 7 |
| H | 2022 | 8 |
Then if Year is selected in the filter I need to run that count over again from 1
FILTER YEAR: 2022
| CODE | YEAR | COUNT |
| D | 2022 | 1 |
| E | 2022 | 2 |
| F | 2022 | 3 |
| G | 2022 | 4 |
| H | 2022 | 5 |
is that possible?
Thanks in advance
Hi,
Please check the below picture and the attached pbix file.
Count measure: =
IF (
HASONEVALUE ( Data[CODE] ),
COUNTROWS ( FILTER ( ALLSELECTED ( Data ), Data[CODE] <= MAX ( Data[CODE] ) ) )
)
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.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!