Skip to main content
cancel
Showing results for 
Search instead 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

Reply
DeepDive
Helper IV
Helper IV

How To Calculate First Date of Quarter and End Date of Quarter Basis Max Invoice Date

Dear AllDear All

Dear All, I need Quarter Start Date and Quarter EndDate on the basis of MaxInvoice Date.. Pls provide the Dax function or calculation for same.. thanks

 

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@DeepDive 

These two measures will convert you [Max InvoiceDate] measure to the start and end of quarter.

Max Date QTR Start = 
DATE ( YEAR ( [Max InvoiceDate] ), ROUNDUP ( DIVIDE ( MONTH ( [Max InvoiceDate] ),3 ),0 ) *3 -2, 1)
Max Date Qtr End = 
EOMONTH ( [Max Date QTR Start],2 )

invoicestrstartend.jpg

View solution in original post

10 REPLIES 10
jgubler
Advocate III
Advocate III

This function does the hard work behind the scenes. Im guessing it is new:
STARTOFQUARTER(<dates>)

 

Source:

https://docs.microsoft.com/en-us/dax/startofquarter-function-dax#:~:text=Returns%20the%20first%20dat...

 

-Joshua

BI_Power_Guy
Frequent Visitor

Thanks to @jdbuchanan71 , was able to create dynamic Current Quarter,Previous Quarter all dates logic .if anyone needs it here you go:

 

define

var _today = date(2022,1,10)
var var1 = {DATE ( YEAR ( TODAY() )-1
ROUNDUP ( DIVIDE ( MONTH ( _today),15 ),0 ) *15 -5, 1)}
var var2 = {DATE ( YEAR ( TODAY() )
ROUNDUP ( DIVIDE ( MONTH ( _today),6 ),0 ) *6 -5, 1)}

var var3= CALCULATETABLE({
if(MONTH(_today) in {1,2,3},
var1,
var2)
}
)

var var4 = DATE( YEAR (TODAY() )
ROUNDUP ( DIVIDE (month(DATE(2022,5,1)),3 ),0 ) *3 -2, 1)-1

EVALUATE
ADDCOLUMNS(CALENDAR(var3,var4),
"name","PQ")

 

Kindly provide a Thumbs ups.

jdbuchanan71
Super User
Super User

@DeepDive 

These two measures will convert you [Max InvoiceDate] measure to the start and end of quarter.

Max Date QTR Start = 
DATE ( YEAR ( [Max InvoiceDate] ), ROUNDUP ( DIVIDE ( MONTH ( [Max InvoiceDate] ),3 ),0 ) *3 -2, 1)
Max Date Qtr End = 
EOMONTH ( [Max Date QTR Start],2 )

invoicestrstartend.jpg

your sulution is very clever, thanks you

I logged in just to give this post a like. Marvelous use of logic to come up with that formula. Saved me a few hours of hair pulling too. Thanks!

Now please explain your work for the class. 😉

 

This was a huge help for me, thank you!

Hello @mchughes 

Certainly, it goes like this.  

Given a month number

Divide that by 3

Then round that up to the nearest whole number

Then multiply that by 3

Then subtract 2

This gives us the number of the first month of the quarter.

Month  / 3 Roundup 0 * 3 - 2
1 0.333333333 1 3 1
2 0.666666667 1 3 1
3 1 1 3 1
4 1.333333333 2 6 4
5 1.666666667 2 6 4
6 2 2 6 4
7 2.333333333 3 9 7
8 2.666666667 3 9 7
9 3 3 9 7
10 3.333333333 4 12 10
11 3.666666667 4 12 10
12 4 4 12 10

 

We combine that with the YEAR of the date and DAY 1 and we get the date of the start of the quarter.

Thanks a lot @jdbuchanan71 

VijayP
Super User
Super User

STARTOFQUARTER and ENDOFQUARTER DAX Functions are available in PowerBI now.

Check Them




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Hi, Thanks for your reply. But I want to calculate Start and End date of Quarter on the basis of a Particular date. StartofQuarter and EndofQuarter will not work here.

Helpful resources

Announcements
Europe Fabric Conference

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 Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors