Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Helper V
Helper V

calculate row count of each year of rolling return years

Hi All,
i hve the below requirement, please check. i have below large dataset with following columns from 2010 till date.some code has data daily wise(365 rows per year) 
and some both monthly and daily  data (12 and 365 rows per year) 
Code,Class name, returns, Date
i am calculating rolling periods( 1 year, 2year till 10 year as below pic) for each code and date selected(Only month end date selection) and its working fine.


My client is asking me to calculate rolling periods if the rowcount matches 365/year for day wise data and 12/year for monthly data.
for ex: for Code 1  from 2022 its daily data and before 2022 ->Monthly data
For 31-dec-2022 and Code 1 selected
1 year(2022)-> check for 365 rows for 2022 year
2 yr 2022,2021 check for 365 rows for 2022 year+ check for 12 rows for 2021 year
3 yr 2022,2021,2020 check for 365 rows for 2022 year+ check for 12 rows for 2021 year+ check for 12 rows for 2020 year
if the rowcount matches then calculate sum of all selected years else display blank.
Please help
How to use a generic way condition to implement this rule
Super User
Super User

@ak77 , Using date table you can create measures like 


Rolling 1 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-1,Year))


Rolling 1  = CALCULATE([Net], WINDOW(-11,REL, 0, REL, ADDCOLUMNS(ALLSELECTED('Date'[Month Year],'Date'[Month Year Sort] ),ORDERBY([Month Year Sort],asc)))




Rolling 2 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-2,Year))


Rolling 2  = CALCULATE([Net], WINDOW(-23,REL, 0, REL, ADDCOLUMNS(ALLSELECTED('Date'[Month Year],'Date'[Month Year Sort] ),ORDERBY([Month Year Sort],asc)))


Create all measures, and if needed add them to calculation groups 




Continue to explore Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD:


Calculation Groups- Measure Slicer, Measure Header Grouping, Measure to dimension conversion. Complex Table display :

Helpful resources

PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors