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
steph_io
Advocate II
Advocate II

Custom Quarter periods used in calculations

I have created a Date Calendar table with my custom fiscal and quarter periods (running from September 1):

 

"FYearQuarter", "FY " & IF(MONTH([Date])>=9,YEAR([Date])+1,YEAR([Date])) & "/Q" & CEILING(IF(MONTH([Date])>=8,(MONTH([Date])-8)/3,(MONTH([Date])+4)/3),1)

 

Now how do I use them in my calculations for QTD and Previous Quarter (for QoverQ growth):

 

AccountsQTD = CALCULATE([Count Accounts],(DATESQTD('Date'[Date])))

AccountsPrvQtr = CALCULATE( [Count Accounts], DATEADD('Date'[Date], -1, QUARTER))

AccountsQOQGrowth = ([Count Accounts] - [AccountsPrvQtr])/[AccountsPrvQtr]

 

The reference to functions: QTD and QUATER no longer applies.

 

Thanks for your help.

6 REPLIES 6
v-huizhn-msft
Employee
Employee

Hi @steph_io,

Have your issue been resolved? If you have not, please feel free to ask. If you have, please mark the corresponding replay as answer, or welcome to share your own solution. More people can fins the workaround quickly and easily. 

Best Regards,
Angelia

The selection of the 'current quarter' works:

CurrentFQuarter = LOOKUPVALUE('Date'[FYearQuarter],'Date'[Date],TODAY())

It looks up the value of TODAY's date in my date table and provides the FiscalYearQuarter.

 

To get Fiscal Quarter over Quarter growth %:

AccountsFPrvQtr = CALCULATE( [Count Accounts], DATEADD('Date'[Date], -1, QUARTER))

AccountsFQOQGrowth = ([Count Accounts] - [AccountsFPrvQtr])/[AccountsFPrvQtr]

This works if I place it in a table visual with the fiscal quarter to group the counts:

"FYearQuarter", "FY " & IF(MONTH([Date])>=9,YEAR([Date])+1,YEAR([Date])) & "/Q" & CEILING(IF(MONTH([Date])>8,(MONTH([Date])-8)/3,(MONTH([Date])+4)/3),1)

FYearQuarterCount AccountsAccountsFPrvQtrAccountsFQOQGrowth
FY 2016/Q4770920-16%
FY 2017/Q18407709%
FY 2017/Q2820840-2%
FY 2017/Q3170500-66%

 

 

But the QuarterToDate is really acting like a count, and not accumulating quarters:

AccountsFQTD = CALCULATE(COUNT(CRMAccounts[E-mail (Primary Contact)]), FILTER('Date','Date'[FYearQuarter] <= 'Date'[CurrentFQuarter]))

 

FYearQuarterYearMonthnumberCount AccountsAccountsFQTD
FY 2016/Q4201606300300
FY 2016/Q4201607290290
FY 2016/Q4201608180180
FY 2017/Q1201609260260
FY 2017/Q1201610260260
FY 2017/Q1201611320320
FY 2017/Q2201612230230
FY 2017/Q2201701270270
FY 2017/Q2201702320320
FY 2017/Q3201703170170

 

 

 

It should be doing this:

YearQuarterYearMonthnumberCount AccountsAccountsQTD
2016/Q2201606300880
2016/Q3201607290290
2016/Q3201608180470
2016/Q3201609260730
2016/Q4201610260260
2016/Q4201611320580
2016/Q4201612230810
2017/Q1201701270270
2017/Q1201702320590
2017/Q1201703170760

 

 

 

 

Hi @steph_io,

Please try the fomrula below.

AccountsFQTD = CALCULATE(COUNT(CRMAccounts[E-mail (Primary Contact)]), FILTER(ALLEXCEPT('Date','Date'[FYearQuarter] ), 'Date'[YearMonthnumber]<= 'Date'[YearMonthnumber]))


Best Regards,
Angelia

Greg_Deckler
Super User
Super User

You would need to use a DAX variable and CALCULATETABLE function with that variable formula and use that in place of the DATESQTD. I would replace your DATEADD -1 and QUARTER with an equivalent number of days -90 DAYS for example.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Can you elaborate on the DATESQTD workaround?

Using a fixed number of days would assume each month has 30 days and would not provide an adequate date range.

DATESQTD returns a table of dates that you are using as a filter. The dates returned are for the quarter to the current date. You just need to simulate this using CALCULATETABLE, something along the lines of:

 

QuarterToDate = 

var CurrentDate = DATE(YEAR(NOW()),MONTH(NOW()),DAY(NOW())) var CurrentQuarter = LOOKUPVALUE( 'Date'[Quarter], 'Date'[Date], CurrentDate) CALCULATETABLE('Dates'[Date], 'Dates'[Quarter]=CurrentQuarter , 'Date'[Date]<=CurrentDate)

Something like that.

 

If you need to be specific in your other case to the exact number of days in the quarter, you should be able to do a similar type of calculation:

 

DaysInQuarter = 

var CurrentDate = DATE(YEAR(NOW()),MONTH(NOW()),DAY(NOW()))
var CurrentQuarter = LOOKUPVALUE( 'Date'[Quarter], 'Date'[Date], CurrentDate)

CALCULATE(COUNTROWS(Date),FILTER(Date,'Date'[Quarter]=CurrentQuarter))

Something like that.

 

 

 

 

 

 

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.