cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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.

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.

How to use a generic way condition to implement this rule
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

Announcements

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors