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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
isam2003
Frequent Visitor

Calculations over Custom Year

Calculations over Custom Year
2 seconds ago

Hello:

 

I have a dataset with columns (Fiscal Year, Fiscal Quarter, Calendar Year, Calendar Quarter, Sales, Indicator) - Sample data attached. 

For each Indicator (eg. "xx") and user choice of Year & Quarter (Q1/Q2/Q3/Q4), I would like to sum up 4 quarters (starting with the user choice of year and quarter) and find the average quarterly sales  as output for each custom year.

I came up with the following but it is not working in all situations such as for eg. if the user selects Oct-Dec quarter of 2021, then the sum would be of the Oct-Dec 2021, Jan-Mar 2022, Apr-Jun 2022 and Jul-Sep 2022 quarters i.e. when the calculation involves quarters spread over two consecutive years. 

VAR __Quarter = SELECTEDVALUE('Quarter'[Quarter])
VAR __Year = SELECTEDVALUE('Year'[Year])

VAR __Result =
SUMX(
FILTER(
'Data',
YEAR('Data'[Date]) = __Year &&
'Data'[Quarter] >= __Quarter &&
'Data'[Quarter] <= __Quarter + 3
),
'Data'[Value]
)

RETURN
__Result

I am not sure if what I am attempting to do is possible within Power BI.  Any guidance would be much appreciated. Thanks in advance. 

FyearFquarterCyearCquarterSalesIndicatorCountry
2022Q22021Q4100xxA
2022Q12021Q3250xxC
2022Q12021Q3600xyC
2022Q32022Q150xzA
2022Q42022Q2250xyD
2022Q12022Q3600xzB
2022Q12022Q3450xxD
2022Q32022Q1550xxE
2022Q22022Q4300xxE
2022Q12022Q3150xzC
2022Q12022Q3450xxB
2022Q22022Q4500xxA
2022Q22022Q4320xxA
2022Q12022Q1150xyD
2022Q32022Q3170xzB
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@isam2003 , You can create calendar using following

Creating Financial Calendar - From Any Month
https://community.powerbi.com/t5/Community-Blog/Creating-Financial-Calendar-Decoding-Date-and-Calend...
https://medium.com/chandakamit/cheat-sheet-calendar-of-any-standard-month-just-one-variable-apart-5e...
https://amitchandak.medium.com/cheat-sheet-power-query-financial-year-calendar-5ceaacb520f1

 

FOR TI

Power BI Custom Period over Period and Period Till Date (PTD)- https://youtu.be/rQ3Z_LtxwQM

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@isam2003 , You can create calendar using following

Creating Financial Calendar - From Any Month
https://community.powerbi.com/t5/Community-Blog/Creating-Financial-Calendar-Decoding-Date-and-Calend...
https://medium.com/chandakamit/cheat-sheet-calendar-of-any-standard-month-just-one-variable-apart-5e...
https://amitchandak.medium.com/cheat-sheet-power-query-financial-year-calendar-5ceaacb520f1

 

FOR TI

Power BI Custom Period over Period and Period Till Date (PTD)- https://youtu.be/rQ3Z_LtxwQM

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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