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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Vladan
Regular Visitor

Dateadd issue with quarter

Hello, 

 

I encountered problem with dateadd function when trying to calculate values from previous quarter. Same problem as in post below:

DateAdd problem with Quarter - Microsoft Power BI Community

This is how my data looks:

Vladan_0-1649750921685.png

Does anyone know why it shows blank only in case of 30/6?

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Vladan 

 

This problem may be due to the fact that DATEADD does not correctly identify the end of the month, and on June 30 he wants to return March 30, but there is no such date in the table.

You can try the function EDATE. https://docs.microsoft.com/dax/edate-function-dax 

vzhangti_0-1650360809576.png

At this time, two dates appear, March 30 and March 31. In order to display the dates of the previous quarter, you can try to specify the data range in the form of Year-month.

vzhangti_1-1650360952841.png

Measure = 
CALCULATE('Table'[Assets 1],FILTER(ALL('Table'),[Year Month]=SELECTEDVALUE('Table'[Last Quarter])))

vzhangti_2-1650361057488.png

Is this the output you expect?

 

Best Regards,

Community Support Team _Charlotte

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
v-zhangti
Community Support
Community Support

Hi, @Vladan 

 

This problem may be due to the fact that DATEADD does not correctly identify the end of the month, and on June 30 he wants to return March 30, but there is no such date in the table.

You can try the function EDATE. https://docs.microsoft.com/dax/edate-function-dax 

vzhangti_0-1650360809576.png

At this time, two dates appear, March 30 and March 31. In order to display the dates of the previous quarter, you can try to specify the data range in the form of Year-month.

vzhangti_1-1650360952841.png

Measure = 
CALCULATE('Table'[Assets 1],FILTER(ALL('Table'),[Year Month]=SELECTEDVALUE('Table'[Last Quarter])))

vzhangti_2-1650361057488.png

Is this the output you expect?

 

Best Regards,

Community Support Team _Charlotte

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

AllisonKennedy
Super User
Super User

@Vladan  the DATEADD Function should only be used with a Date dimension table - do you have a dimDate table you can use in the formula instead of the DAtaMerged[Date] ?


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

@AllisonKennedy 

I have a calendar table that is connected to my maiin table. I changed the measure but no luck in desired outcome.

This is how it all looks now:

Vladan_0-1649765194056.png

Vladan_1-1649765246198.pngVladan_2-1649765289460.png

 

amitchandak
Super User
Super User

@Vladan , Dateadd needs continuous dates , Please use a date table and try

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...

 


To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.