cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Junkay
Regular Visitor

Time intelligence function returning wrong month

Hi All,

 

I'm tring to extract month from date column in the table shown below. But I'm getting wrong month. For the month of July, Jan is returned in the month column. Please what could be the issue? I have checked my formula over and over again, but don't see anything wrong.

Junkay_0-1695522580109.png

 

3 ACCEPTED SOLUTIONS
OwenAuger
Super User
Super User

Hi @Junkay 

Change line 3 of the code to

 

"Month", FORMAT ( [DATE], "mmm" ),

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

Hi again @Junkay 

The ENDOFMONTH function will produce the expected result as long as the column reference provided as an argument is for a column which contains complete calendar months. If any dates are missing, this function treats the last available date in a given calendar month as the last day of the month. The tutorial you were using may have already had a table containing complete months.

 

For this reason, I would generally not advise using ENDOFMONTH to return a scalar end-of-month value. EOMONTH is the best function for this.

 

ENDOFMONTH is typically used within CALCULATE to modify a date filter by shifting it to the last day of the last visible month. ENDOFMONTH returns a 1x1 table which retains lineage to the column reference passed as its argument.

 

On to your latest question, to return an end-of-quarter date, I would advise using EOMONTH again.

For standard calendar quarters (Jan-Mar, Apr-Jun etc), an expression like this should work:

 

EOMONTH ( [Date], MOD ( - MONTH ( [Date] ), 3 ) )

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

Hi Owen,

 

You are a genius. Thank you so much for the support.

 

I wish I could be this proficient.

 

Thanks a million times.

View solution in original post

6 REPLIES 6
Junkay
Regular Visitor

Thanks greatly Owen,

 

EOMONTH function worked. But I wonder why ENDOFMONTH get accurate result in the tutorial I was using, but not working for me. Also, I have same challenge with ENDOF QUARTER function. It’s not returning the last day of the quarter. I’m not sure there’s EOQUARTER function in Power BI.

 

Formula:

 

Junkay_0-1695535059593.png

 

 

Result:

 

Junkay_1-1695535059597.png

 

 

Thanks Owen.

Hi again @Junkay 

The ENDOFMONTH function will produce the expected result as long as the column reference provided as an argument is for a column which contains complete calendar months. If any dates are missing, this function treats the last available date in a given calendar month as the last day of the month. The tutorial you were using may have already had a table containing complete months.

 

For this reason, I would generally not advise using ENDOFMONTH to return a scalar end-of-month value. EOMONTH is the best function for this.

 

ENDOFMONTH is typically used within CALCULATE to modify a date filter by shifting it to the last day of the last visible month. ENDOFMONTH returns a 1x1 table which retains lineage to the column reference passed as its argument.

 

On to your latest question, to return an end-of-quarter date, I would advise using EOMONTH again.

For standard calendar quarters (Jan-Mar, Apr-Jun etc), an expression like this should work:

 

EOMONTH ( [Date], MOD ( - MONTH ( [Date] ), 3 ) )

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Hi Owen,

 

You are a genius. Thank you so much for the support.

 

I wish I could be this proficient.

 

Thanks a million times.

Junkay
Regular Visitor

Thank you so much, Owen. This resolved it.

 

But I have another challenge. My End of Month function is also returning wrong result:

 

Formular below:

 

Junkay_0-1695527020734.png

Result below:

Junkay_1-1695527098466.png

 

Thanks for your support.

 

@Junkay Glad to hear it 🙂

If you want to return the end-of-month date as a scalar value, you should use the EOMONTH function (which works the same as in Excel).

In your example:

 

 

EOMONTH ( Orders[Order Date], 0 )

 

 

 

ENDOFMONTH is a time intelligence function, normally used to modify date filters. It will return a single-column/single-row table containing the last date of a month from the set of dates that exist in the column referenced.

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn
OwenAuger
Super User
Super User

Hi @Junkay 

Change line 3 of the code to

 

"Month", FORMAT ( [DATE], "mmm" ),

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors