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
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, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

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, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

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, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
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

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.