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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
SuzieKidd
Frequent Visitor

SQL to DAX

Hi, Can someone please help me, I need to write the following SQL in DAX 

 

DATEADD(s,-1,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)))

 

Thanks in advance

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @SuzieKidd ,

 

This is the correspondence between the sql function and the DAX function, please replace GETDATE() with today() or now().

vtangjiemsft_0-1675837122437.png

Please refer to the following document for more information.

DATEADD function (DAX) - DAX | Microsoft Learn

DATEDIFF function (DAX) - DAX | Microsoft Learn

 

Best Regards,

Neeko Tang

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
Anonymous
Not applicable

Hi @SuzieKidd ,

 

This is the correspondence between the sql function and the DAX function, please replace GETDATE() with today() or now().

vtangjiemsft_0-1675837122437.png

Please refer to the following document for more information.

DATEADD function (DAX) - DAX | Microsoft Learn

DATEDIFF function (DAX) - DAX | Microsoft Learn

 

Best Regards,

Neeko Tang

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

@SuzieKidd , We have Datediff also in DAX.

 

But dateadd requires continuous dates

 

In case you need to subtract day , just do [mm] - 7

 

else use date as date add

 

https://community.powerbi.com/t5/Community-Blog/Date-as-Dateadd-Decoding-Date-and-Calendar-5-5-Power...

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.