Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ashwinkolte
Helper I
Helper I

Question about end of month formula

Hi 

 

Can somebody please tell me why End of month formula is working for 1 jul 22 but not working for 1 jul 23 ? Screeshot below of a table view 

 

 

ashwinkolte_0-1693383041412.png

 

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @ashwinkolte 

If you  want to return the last day of the year/month of 'Calendar'[Date] in a calculated column, I would instead suggest:

End of month =
EOMONTH ( 'Calendar'[Date], 0 )

The ENDOFMONTH function is one of the time intelligence functions that normally used for modifying filters within CALCULATE/CALCULATETABLE.

It returns a 1x1 table which contains the last day that exists in that column in the same month/year of the maximum date in the filter context.

Behind the scenes the date column reference is actually converted to

CALCULATETABLE ( DISTINCT ( 'Calendar'[Date] ) )

See https://dax.guide/ENDOFMONTH/ for more info.

 

ENDOFMONTH (and other time intelligence functions) are restricted to returning dates that actually exist in the referenced column, so my guess is that the maximum value of 'Calendar'[Date] in July 2023 is 1-July-2023, while the max value in July 2022 is 31-July-2022. You could also solve your issue by ensuring 'Calendar' contains complete calendar months (which is best practice in general).

 

Regards

 


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

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

Hi @ashwinkolte 

If you  want to return the last day of the year/month of 'Calendar'[Date] in a calculated column, I would instead suggest:

End of month =
EOMONTH ( 'Calendar'[Date], 0 )

The ENDOFMONTH function is one of the time intelligence functions that normally used for modifying filters within CALCULATE/CALCULATETABLE.

It returns a 1x1 table which contains the last day that exists in that column in the same month/year of the maximum date in the filter context.

Behind the scenes the date column reference is actually converted to

CALCULATETABLE ( DISTINCT ( 'Calendar'[Date] ) )

See https://dax.guide/ENDOFMONTH/ for more info.

 

ENDOFMONTH (and other time intelligence functions) are restricted to returning dates that actually exist in the referenced column, so my guess is that the maximum value of 'Calendar'[Date] in July 2023 is 1-July-2023, while the max value in July 2022 is 31-July-2022. You could also solve your issue by ensuring 'Calendar' contains complete calendar months (which is best practice in general).

 

Regards

 


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

Thanks for the explanation !

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.