Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

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

  • 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] ) ) )
    )
    

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for getting back to me

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

       

      Thanks!

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

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