cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MIKAOKSA
Helper I
Helper I

Date filter in SUM

I need to add date filter to sum calculation. My current formula is this:

 

AMOUNT_STOCK divided by AMOUNT_LOC_NOTAX =
DIVIDE(
    SUM('MET_PURCHASE'[AMOUNT_STOCK]),
    SUM('INV_HEADER'[AMOUNT_LOC_NOTAX])
 
I need AMOUNT_STOCK filtered last calendar month and AMOUNT_LOC_NOTAX filtered last 12 calendar months. How to do this?
 
Appreciate if someone would help.
 
BR, 
Mika
1 ACCEPTED SOLUTION
Tahreem24
Super User II
Super User II

@MIKAOKSA you could try something like this:

 =
VAR LastMonth_AmtStock = CALCULATE(SUM('MET_PURCHASE'[AMOUNT_STOCK]),PREVIOUSMONTH(DateTable[DateColumn]))
VAR LastYear_AmtStock = CALCULATE(SUM('INV_HEADER'[AMOUNT_LOC_NOTAX]),DATEADD(DateTable[DateColumn],-12,MONTH))
RETURN DIVIDE(LastMonth_AmtStock,LastYear_AmtStock)
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, and Sales Analysis Report

View solution in original post

5 REPLIES 5
Tahreem24
Super User II
Super User II

@MIKAOKSA you could try something like this:

 =
VAR LastMonth_AmtStock = CALCULATE(SUM('MET_PURCHASE'[AMOUNT_STOCK]),PREVIOUSMONTH(DateTable[DateColumn]))
VAR LastYear_AmtStock = CALCULATE(SUM('INV_HEADER'[AMOUNT_LOC_NOTAX]),DATEADD(DateTable[DateColumn],-12,MONTH))
RETURN DIVIDE(LastMonth_AmtStock,LastYear_AmtStock)
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, and Sales Analysis Report

View solution in original post

This worked like a charm, thank you!

@MIKAOKSA Awesome. Good to know.

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, and Sales Analysis Report
manikumar34
Solution Sage
Solution Sage

@MIKAOKSA , 

 

Use DATESINPERIOD or DATESBETWEEN functions to achieve this.





If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




amitchandak
Super User IV
Super User IV

@MIKAOKSA , You can try a measure with date table like

 

Rolling 12 = CALCULATE([AMOUNT_STOCK divided by AMOUNT_LOC_NOTAX],DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH))

 

If you need a trend then refer -https://www.youtube.com/watch?v=duMSovyosXE



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!

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors