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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
ak77
Post Patron
Post Patron

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.
ak77_0-1696026863075.png

 

 
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
1 REPLY 1
amitchandak
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)))

 

or

 

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: https://youtu.be/nxc_IWl-tTc
https://medium.com/@amitchandak/power-bi-window-function-3d98a5b0e07f

 

Calculation Groups- Measure Slicer, Measure Header Grouping, Measure to dimension conversion. Complex Table display : https://youtu.be/qMNv67P8Go0

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors