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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
transcend
Frequent Visitor

Need help converting date functions from SQL Server to DAX

Hello, I am trying to convert the following date function from t-sql to dax:

 

select
EOMONTH(DATEADD (dd, -1, DATEADD(qq, DATEDIFF(qq, 0, myDateCol) +1, 0)), 1)
;

 

So far I have DATEDIFF as  

DATEDIFF( 0, myDateCol, QUARTER) 

 

however I can't figure out how to do DATEADD. For that I have this:

DATEADD(0, DATEDIFF( 0, myDateCol, QUARTER)+1, quarter)  

 I got this function from https://dax.guide/dateadd/

 

I know EOMONTH exists in DAX as show here: https://docs.microsoft.com/en-us/dax/endofmonth-function-dax

I was hoping someone can provide my a hint or help me. Thank you.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@transcend , Assuming you can add three month in place of quarter

Datediff will give number, so not sure how you are using that

 

Datediff([Date1], [Date2], Day) //in place of date you can use month, quarter, year etc

 

 

In place of dateadd, you have to use date

 

say 3 month in place of quarter

 

date(Year([MyDate]),Month([MyDate])-1, Day([MyDate]))

 

Subtract or add days simply

[MyDate] + [Days]

 

[MyDate]+5

 

For end of the month

 

eomonth([MyDate], 0) //current month end date

 

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

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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@transcend , Assuming you can add three month in place of quarter

Datediff will give number, so not sure how you are using that

 

Datediff([Date1], [Date2], Day) //in place of date you can use month, quarter, year etc

 

 

In place of dateadd, you have to use date

 

say 3 month in place of quarter

 

date(Year([MyDate]),Month([MyDate])-1, Day([MyDate]))

 

Subtract or add days simply

[MyDate] + [Days]

 

[MyDate]+5

 

For end of the month

 

eomonth([MyDate], 0) //current month end date

 

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

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

Thank you.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.