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
alevandenes
Helper IV
Helper IV

Subtract one month from date column

Hi Community,

 

I need to create a calculated column that subtracts one month from an Invoice date column.

The formula needs to be valid also for the change of the year.

 

[DATEADD works but only for a couple of rows..not sure why]

 

Can someone help me out here?

Thanks in advance

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @alevandenes

 

Try using EDATE function (DAX)

Column = EDATE([Date],-1)

vjingzhang_0-1670317608127.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

7 REPLIES 7
v-jingzhang
Community Support
Community Support

Hi @alevandenes

 

Try using EDATE function (DAX)

Column = EDATE([Date],-1)

vjingzhang_0-1670317608127.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

CLQ
Helper I
Helper I

I don't quite understand, you can use the function: Month('ColumnName')

or, if you want year and month number, something like:

concatenate(year(ColumnName),
month(ColumnName)).

(and in the event that you always want a leading zero, an if >0 and another concatenate would be nice)


I don't know if it's what you were looking for. If you can give an example, better 😁

KNP
Super User
Super User

DATEADD is the correct function to use.

Please provide some sample data, pasted as data.

Please explain what happens for the rows it is not working for. 

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x
Nofil098
Resolver I
Resolver I

Take a month from a date column like this: 
var Month_Name = Month(Datecolumn_name)
return Month_name-1
OR 

You can also use Previous Month Function

This doesnt work as it is only taking the month number minuts one.

it doesnt account for change of the year

 

thanks anyways

vaibhavkale570
Resolver III
Resolver III

Have you tried PREVIOUSEMONTH dax function?

apparently it doesnt work with a table, but only with a single value specified

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.