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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
JulieL4108
Regular Visitor

Looking for correct SQL for Previous Month of Column to create a new column

PREVIOUSMONTH('Query1[Date_field]) not working [Date_field] references a column in the table, but no returns of prior month of the date?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @JulieL4108 

If you want to add a calculated column by dax,You can use edate() function. 

e.g 

Column =
EDATE ( 'Query1'[Date_field], -1 )

Output

vxinruzhumsft_1-1704421662538.png

If you want to implement it in power query, you can add a custom column and input the following code

Date.AddMonths([Date_field],-1)

Output

vxinruzhumsft_0-1704421609639.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
JulieL4108
Regular Visitor

Apologies I am new and may not have asked the question properly.  I have a date column and want to create a new date column 1 month prior than the original date column.  

Anonymous
Not applicable

Hi @JulieL4108 

If you want to add a calculated column by dax,You can use edate() function. 

e.g 

Column =
EDATE ( 'Query1'[Date_field], -1 )

Output

vxinruzhumsft_1-1704421662538.png

If you want to implement it in power query, you can add a custom column and input the following code

Date.AddMonths([Date_field],-1)

Output

vxinruzhumsft_0-1704421609639.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you!  I kept adding in 'm' in the front of the field EDATE('m','Query1'[date_field],-1) thinking I needed to indicate month and kept receiving an error.

EDATE (<column> , -1 )

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.