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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Jkaelin
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

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

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

 

 

 

@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

@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

zoloturu
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

@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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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