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

View all the Fabric Data Days sessions on demand. View schedule

Reply
lasmithfla
Helper I
Helper I

Need help with Calc to only use the ending date of a filter selected in one of the charts

I have a situation where I may have a chart showing 12 months of data based on the time period selected in the slicer, could be any range but typical is 12 month view.  I also want a card to show a year over year growth based on previous 12 months compared to 12 months prior to that (24 months back).  I want the YOY growth time to start with whatever the ending date in the slicer is selected.

 

So as example - slicer shows 1/1/18 to 1/1/19 - the graph will only show these months BUT i want the YOY growth to go back 24 months from 1/1/19.

 

lasmithfla_0-1596740691002.png

 

Here are my calcs

 

Sales_Last12MonthsSelected = sumx(DATESINPERIOD(Sales[Date],LASTDATE(Sales[Date]),-12,Month),[Sum Sales])
 
12monthAvg = [Sales_Last12MonthsSelected] /
Calculate(DISTINCTCOUNT(Sales[Date]),
DATESINPERIOD(Sales[Date],
LASTDATE(Sales[Date]),-12,MONTH))
 
Prior12MonthAvg = CALCULATE([12monthAvg],SAMEPERIODLASTYEAR(Sales[Date]))
 
YOY Growth = Divide([12monthAvg]-[Prior12MonthAvg],[Prior12MonthAvg])
 
 
4 REPLIES 4
V-lianl-msft
Community Support
Community Support

Hi @lasmithfla ,

 

I'm not sure I fully understand your intention.

Try to modify YOY Growth = Divide(([12monthAvg]+[Prior12MonthAvg])/2-[Prior12MonthAvg],[Prior12MonthAvg])

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Sorry if I didn't explain well - I want the YOY growth based on 24 months regardless of dates selected in the slicer.

There will be multiple visuals on the page, a graph that can have as many months as user wants to show; more than likely 12 months of data.  The YOY would be a card, based on doing the calculation from the ending date selected in the slicer to determine the 24 months back of data that I need.

 

So it would be from the last date in the slicer - 12 months, and then 12 months prior to that.   I'm struggling with getting the

data to not adjust with the slicer.

Greg_Deckler
Community Champion
Community Champion

@lasmithfla - You will need to use ALL or ALLEXCEPT to break filter context and then filter back down to what you want. 

 

You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  Would you mind showing me the calc with the filter in it? I'm pretty new to this!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors