Forum Discussion
Custom QTD Calculations
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.
- GuillaumeB6 years agoHelper I
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.
- amitchandak6 years agoSuper User
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