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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

capture last month and back from a date column

Hi all,

 

I have a column with dates in the following format:

dd/mm/yyyy (sample data below)

 

How can I create a calculated column that only captures any date in last moth and backwards. All dates in current month or in future to be ignored. 

 

Thank you in advance.

 

Date column
16/12/2021
17/12/2021
18/12/2021
21/12/2021
22/12/2021
13/01/2022
14/01/2022
15/01/2022
26/01/2022
23/02/2022
24/02/2022
25/02/2022
01/03/2022
18/03/2022
22/03/2022
24/03/2022
25/03/2022
26/03/2022
28/03/2022
29/03/2022
30/03/2022
31/03/2022
01/04/2022
02/04/2022
04/04/2022
05/04/2022
06/04/2022
07/04/2022
08/04/2022
09/04/2022
16/12/2022
24/02/2023
25/02/2023
18/05/2023

05/12/2023

 

 

2 ACCEPTED SOLUTIONS
AlexisOlson
Super User
Super User

The EOMONTH function is nice here.

CalculatedColumn = 
VAR _LastMonthEnd = EOMONTH ( TODAY(), -1 )
RETURN
    IF ( [Date column] <= _LastMonthEnd, [Date column] )

 

AlexisOlson_0-1647541295000.png

View solution in original post

Anonymous
Not applicable

Thank you @AlexisOlson .... its working perfectly 🙂

View solution in original post

4 REPLIES 4
AlexisOlson
Super User
Super User

The EOMONTH function is nice here.

CalculatedColumn = 
VAR _LastMonthEnd = EOMONTH ( TODAY(), -1 )
RETURN
    IF ( [Date column] <= _LastMonthEnd, [Date column] )

 

AlexisOlson_0-1647541295000.png

Anonymous
Not applicable

Thank you @AlexisOlson .... its working perfectly 🙂

serpiva64
Super User
Super User

Hi,

You can obtain this

serpiva64_0-1647539692891.png

with this calculated column

Column =
var currentdate = 'Table'[Date column]
var prevmonth = date(YEAR(TODAY()),MONTH(TODAY())-1,DAY('Table'[Date column]))
var result =if (currentdate> prevmonth,"",FORMAT('Table'[Date column],"DD/MM/YYYY"))
return
result
 

If this post is useful to help you to solve your issue consider giving the post a thumbs up 

 and accepting it as a solution !

 

 

 

rsbin
Super User
Super User

@Anonymous 

Create a new Custom Column.  Something like this should work.

IsBeforeCurrentMonth = IF( YEAR([Date column]) <= YEAR(TODAY() ) &&
                            MONTH([Date column] ) < MONTH( TODAY() ),
                            TRUE,
                            FALSE )

Add this Column to your Filter Panel and select True.

Hope this works for you.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.