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

Previous Day Sales DAX not working

I can't seem to get the previous day sales DAX to work:

 

Previous Day Sales = CALCULATE(SUM(AssaySales[Extended Sales PMAR Amount], PREVIOUSDAY('AssaySales'[Ship Date (MM/DD/YYYY)]))). The error says there's an unexpected parameter ', PREVIOUSDAY('AssaySales'[Ship Date (MM/DD/YYYY)])'
 
I've added two pictures of my table (same table, two separate screenshots because the table was so large).
 
Ship Date.PBI.JPGSales.PBI.JPG
 
Any thoughts?
1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

@Anonymous  - when troubleshooting DAX errors, look for where the red squiggly underline begins - you're missing a close bracket near that point after the SUM function, see in bold red below: 

 

Previous Day Sales = CALCULATE(SUM(AssaySales[Extended Sales PMAR Amount] ), PREVIOUSDAY('AssaySales'[Ship Date (MM/DD/YYYY)] ) )

 

Also, very IMPORTANT, you need a DimDate table for the PreviousDay function to work properly: https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html 


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

View solution in original post

4 REPLIES 4
naveenmechu
Helper I
Helper I

Hi,

You missed to close sum function, use below one--

Previous Day Sales = CALCULATE(SUM(AssaySales[Extended Sales PMAR Amount], PREVIOUSDAY('AssaySales'[Ship Date (MM/DD/YYYY)])))

 

and its better if you create seprate date table.

 

Let me know, if you still face chellenge.

 

Thanks

Naveen Mechu

Anonymous
Not applicable

@AllisonKennedy  here's the DAX with the DimDate suggestion. 

 

Previous Day Sales = CALCULATE(SUM(AssaySales[Extended Sales PMAR Amount]),PREVIOUSDAY('DimDate'[Date].[Date]))
 
It's still not populating an accurate value. It's calculating the sum of the last two years (2020 and 2021), which is the date range of my dataset. It seems like I need to do an IF function but I don't know how to do that in Power Bi, only excel. Mind helping? 

@Anonymous what are you trying to get? I use DATEADD function for most basic scenarios, not sure if that's what you're looking for here?

 

Previous Day Sales = CALCULATE(SUM(AssaySales[Extended Sales PMAR Amount]),

DATEADD('DimDate'[Date],-1, DAY)

)


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
Super User
Super User

@Anonymous  - when troubleshooting DAX errors, look for where the red squiggly underline begins - you're missing a close bracket near that point after the SUM function, see in bold red below: 

 

Previous Day Sales = CALCULATE(SUM(AssaySales[Extended Sales PMAR Amount] ), PREVIOUSDAY('AssaySales'[Ship Date (MM/DD/YYYY)] ) )

 

Also, very IMPORTANT, you need a DimDate table for the PreviousDay function to work properly: https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html 


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

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.