cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver I
Resolver I

Sales For End of Month 2 Months Ago

Good morning,

 

I'm trying to capture the sales for a specified date.  Based on the date I select, I want to capture the sales as of the last day in the month (2 months ago).  

 

For example:  If I select 11/20/2019.  I want to return the sales for 9/30/2019.

For example: If I select 12/1/2019.  I want to return the sales for 10/31/2019.  

For example:  If I select 1/1/2020.  I want to return the sales for 11/30/2019.

 

I've tried several iterations but unable to get it to work.  I do have a date table.  An example below of a measure that did not work.

=CALCULATE(Sum(sales),Filter(All(Date),Date=EOMONTH(DATe,-2)

 

Thank you!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

@amitchandak @zoloturu 

Hi Guys, thank you again for your help.  I have figured out the correct solution for my custom needs.  

 

It's CALCULATE (sum(Sales),PreviousDay(DATEADD('Date'[Date],-1,Month)))

 

Thank you again very much.  Best regards - James

View solution in original post

5 REPLIES 5
Highlighted
Memorable Member
Memorable Member

Hi @Jkaelin ,

 

Try this one (check table names and set proper ones if needed):

 

measure =
CALCULATE (
    SUM ( 'Table name'[sales] ),
    FILTER ( ALL ( 'Date' ), 'Date'[Date] = EOMONTH ( 'Date'[Date], -2 ) )
)

 

Please consider, following format for DAX calculations:

 

'Table' - for tables mention table in apostrophes

'Table'[Column] - for columns you need to mention table name (in an aforementioned format) and a column name with square brackets

[Measure] - measure name with square brackets without table name

 


Regards,
Ruslan Zolotukhin (zoloturu)
BI Engineer at Akvelon Inc. / Kharkiv Power BI User Group Leader / DAX & Power BI Trainer
-------------------------------------------------------------------
Did I answer your question? Mark my post as a solution!
It was useful? Press Thumbs Up!

You are from Ukraine? If yes then welcome to Power BI User Group - KhPUG website. Other country? Check and find proper one - Power BI User Groups

Highlighted
Super User IV
Super User IV

The first example seems wrong. Seem like you want 60 days behind

 

 

2 Months behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-2,Month))
60 Days behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-60,Day))

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

 

 

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Highlighted

@zoloturu  Hi, thank you for the response.  I appreciate the help.  It appears the formula you provided is the same formula I posted in my question.  For whatever reason, that doesn't work.  

 

Best regards, James

Highlighted

@amitchandakHi, thank you for your help.  Your response is close.  It's providing a trailing value, either exactly 2 months ago or exactly 60 days ago.  I'm trying to find the "End of Month" value for 2 months ago.  

 

So for example:  Today (1/21/2020) - I want to pull the sales for (11/30/2019).

 

Any tips?

 

Kindly - James

Highlighted

@amitchandak @zoloturu 

Hi Guys, thank you again for your help.  I have figured out the correct solution for my custom needs.  

 

It's CALCULATE (sum(Sales),PreviousDay(DATEADD('Date'[Date],-1,Month)))

 

Thank you again very much.  Best regards - James

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors