Forum Discussion
Custom QTD Calculations
amitchandak wrote:GuillaumeB, Create Rank for then Quarters, then you Rank to get Qtr, Last Qtr QOQ
You need Qtr start date. Based on that you can calculate day of qtr and get QTD
I got it like this
Start of Year = STARTOFYEAR(Dates[Date],"1/31") // Start of year can take a start date
Strat of Qtr = date(year(Dates[Start of Year]), month(Dates[Start of Year])+Dates[Add Qtr],1)
Day of Qtr = DATEDIFF([Start of Q],[Date],Day)+1
Qtr No = "Q"& QUOTIENT(DATEDIFF('Date'[Start Of Year], 'Date'[Date],MONTH),3)+1
QTD = CALCULATE([Measure], FILTER(ALL(Dates), Dates[Qtr Rank] =max(Dates[Qtr Rank]) && Dates[Day of Qtr ] <= Max(Dates[Day of Qtr ])))
Last QTD = CALCULATE([Measure], FILTER(ALL(Dates), Dates[Qtr Rank] =max(Dates[Qtr Rank])-1 && Dates[Day of Qtr ] <= Max(Dates[Day of Qtr ])))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184
Appreciate your Kudos.
How does this:
Strat of Qtr = date(year(Dates[Start of Year]), month(Dates[Start of Year])+Dates[Add Qtr],1)
Work exactly? What am I supposed to putt for "Dates[Add Qtr]"
Also will this be static? 2020 started on December 29th, 2019 so PBI needs to automatically detect that 2021 will start on December 30th, 2020.
GuillaumeB , missed columns
Add Qtr = QUOTIENT(DATEDIFF(Dates[Start of Year], Dates[Date],MONTH),3)*3
Qtr Rank = RANKX(ALL(Dates),Dates[Strat of Qtr],,ASC,Dense)- amitchandak6 years agoSuper User
GuillaumeB , it can dynamic, if the start of the year is the same date every year like 12/30. If not we need to build qtr start logic
- GuillaumeB6 years agoHelper I
I'm not sure what I SHOULD be getting as a result but this isn't right. Here is a sample from Q1 to show you
Date WeekEnding Quarter Start of Year Strat of Qtr Add Qtr Qtr Rank 2/24/2020 2/28/2020 Q1 12/29/2019 0:00 12/1/2019 0:00 0 21 2/25/2020 2/28/2020 Q1 12/29/2019 0:00 12/1/2019 0:00 0 21 2/26/2020 2/28/2020 Q1 12/29/2019 0:00 12/1/2019 0:00 0 21 2/27/2020 2/28/2020 Q1 12/29/2019 0:00 12/1/2019 0:00 0 21 2/28/2020 2/28/2020 Q1 12/29/2019 0:00 12/1/2019 0:00 0 21 2/29/2020 2/28/2020 Q1 12/29/2019 0:00 12/1/2019 0:00 0 21 3/1/2020 3/6/2020 Q1 12/29/2019 0:00 3/1/2020 0:00 3 21 3/2/2020 3/6/2020 Q1 12/29/2019 0:00 3/1/2020 0:00 3 21 3/3/2020 3/6/2020 Q1 12/29/2019 0:00 3/1/2020 0:00 3 21 Here is what I'm getting. The Quarter column is what I SHOULD be using as a quarter indicator but instead the Add Qtr is 0 until Feb 29th and then starts at 3 but our Q2 doesn't start until Apr-24th. Again, this isn't normal, all equal quarters, hence why I need to use a set of custom dates.