Forum Discussion

bimchahaha's avatar
bimchahaha
Icon for Microsoft Employee rankMicrosoft Employee
5 years ago
Solved

Rolling count for all the years

How can I rolloing count for all the years I have in the table .?

suppose original table

ID     Date

1       1/1/2020

2        1/2/2020

3       1/3/2020

4       1/1/2021

5       1/2/2021

6       1/3/2021

7       1/4/2021

 

and give

               2020      2021

Count     3              7

 

??

 

 

2 Replies

  •  

     

    Count Measure : =
    VAR _currentyear =
    MAX ( 'Year'[Year] )
    RETURN
    IF (
    HASONEVALUE ( 'Year'[Year] ),
    CALCULATE ( COUNTROWS ( Data ), 'Year'[Year] <= _currentyear )
    )

     

     

    Link to the sample pbix file 

     

     

  • bimchahaha 

    If you don't have a date table. you can create a year column

    year = year('Table'[Date])
    and create a measure
    Measure = COUNTX(FILTER(all('Table'),'Table'[year]<=max('Table'[year])),'Table'[Date])
    pls see the attachment below