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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Gaurav_84
Helper I
Helper I

Dax Generate function

Hi Expert,

 

Please help me with below DAX function it was share with me in my older post. Is there any way to achieve M-1 from effective date.

Suppose if my effective date is 22/10/2020 with m-1 it should become 22/09/2020.

Gaurav_84_0-1603326033152.png

 

Regards

Gaurav

 

 

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @Gaurav_84 

 

It’s my pleasure to answer for you.

According to your description, I think you can define a variable as ‘m-1’date.

Like this:

 

Measure = 
var dateymd=MAX('Table'[Effective date])
var year=YEAR(dateymd)
var month=MONTH(dateymd)-1
var day=DAY(dateymd)
var effevtivedate=DATE(year,month,day)
return effevtivedate

 

v-janeyg-msft_0-1603691833233.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

2 REPLIES 2
v-janeyg-msft
Community Support
Community Support

Hi, @Gaurav_84 

 

It’s my pleasure to answer for you.

According to your description, I think you can define a variable as ‘m-1’date.

Like this:

 

Measure = 
var dateymd=MAX('Table'[Effective date])
var year=YEAR(dateymd)
var month=MONTH(dateymd)-1
var day=DAY(dateymd)
var effevtivedate=DATE(year,month,day)
return effevtivedate

 

v-janeyg-msft_0-1603691833233.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

amitchandak
Super User
Super User

@Gaurav_84 , Not very clear. Try this formula

=
var _min =Minx(allselected(table),Table[[finish_dt]])
var _max = date(year(_min), month(_min)-1,day(_min))
return
return
calculate([measure], filter(Date, Date[Date] >=_min && Date[Date]>=_min))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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