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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Vijay08V
Helper III
Helper III

DAX to find LastDate of Previous Month

Hi,

 

I need help in writing a DAX function to find the last date of previous month from Date Column based on the Date filter selection. For example If I select 23-08-22 date, function should be able to throw output 29-07-22 as last date of previous month. Below is the sample date column data. 

 

Date
18-07-2022
19-07-2022
20-07-2022
21-07-2022
22-07-2022
25-07-2022
26-07-2022
27-07-2022
28-07-2022
29-07-2022
01-08-2022
02-08-2022
03-08-2022
04-08-2022
05-08-2022
08-08-2022
09-08-2022
10-08-2022
11-08-2022
12-08-2022
15-08-2022
16-08-2022
17-08-2022
18-08-2022
19-08-2022
22-08-2022
23-08-2022
2 ACCEPTED SOLUTIONS
jgeddes
Super User
Super User

You can try:

Last Date In Previous Month =
var _selectedDate =
SELECTEDVALUE(dates_List[Date])
var _previousMonth =
month(EOMONTH(_selectedDate,-1))
Return
CALCULATE(
    MAX(dates_List[Date]),
    MONTH(dates_List[Date]) = _previousMonth
)
 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a measure.

 

Picture1.png

 

Expected output measure: =
VAR _previousmonthenddate =
    EOMONTH ( MAX ( Data[Date] ), -1 )
VAR _result =
    MAXX (
        FILTER ( ALL ( Data[Date] ), Data[Date] <= _previousmonthenddate ),
        Data[Date]
    )
RETURN
    _result

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

View solution in original post

3 REPLIES 3
Vijay08V
Helper III
Helper III

It worked! Thank you.

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a measure.

 

Picture1.png

 

Expected output measure: =
VAR _previousmonthenddate =
    EOMONTH ( MAX ( Data[Date] ), -1 )
VAR _result =
    MAXX (
        FILTER ( ALL ( Data[Date] ), Data[Date] <= _previousmonthenddate ),
        Data[Date]
    )
RETURN
    _result

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

jgeddes
Super User
Super User

You can try:

Last Date In Previous Month =
var _selectedDate =
SELECTEDVALUE(dates_List[Date])
var _previousMonth =
month(EOMONTH(_selectedDate,-1))
Return
CALCULATE(
    MAX(dates_List[Date]),
    MONTH(dates_List[Date]) = _previousMonth
)
 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.