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

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

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

@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 !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

Helpful resources

Announcements
Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Power BI Womens Summit 2021 768 x460.jpg

Interviews, learning sessions, allies, and more!

#PowerBIWomenSummit

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

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