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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Do not filter data from a measure with a slicer

Hi,

I'm trying to display over time a graph with both my KPI value and the 6 month rolling average.

I calculated the 6RMA using the following formula :

CALCULATE(
SUM(CompletedKPIView[KPI Value])/6;
DATESINPERIOD((Campaign[MonthDateTime]); MAX(Campaign[MonthDateTime]); -6; MONTH)
 
The datas are correct when I display over all the years.
However, when I filter the data over a specific year, the data calculated in the 6RMA are wrong for the 5 first months. PowerBI doesn't include data from the previous year in the calculus when a slicer is used.
 
Capture.PNG
I have tried using an ALL(Campaign) at the end of my calculus. It does work but when I filter in my graph, all the years are displayed, not only the selected one.
 
Capture2.PNG
 
 
 
Thanks for your help
6 REPLIES 6
Anonymous
Not applicable

DATESINPERIOD will work correctly only on DATE TABLES. I presume that Campaign is not a date table. Please create a proper date table in your model, mark it as such and connect to your fact tables. Then and only then will you get correct answers from time-intel functions.

Best
D
Anonymous
Not applicable

This is a Date Tables linked to the fact table.
The datas are correct, but not when a slicer is used. Data calculated between January and May are wrong as the months from the previous year are not all taken into account.

Anonymous
Not applicable

@Anonymous, please do yourself a favor and watch this: https://www.sqlbi.com/tv/time-intelligence-in-microsoft-power-bi/

 

Many thanks.


Best
D

Anonymous
Not applicable

I understood what you meant by proper date table. I managed to solve my problem. Thanks !

Anonymous
Not applicable

OK. Good.

Best
D
Anonymous
Not applicable

So, you're saying that Campaign is a proper Date table marked as such in the model? If it were, then DATESINPERIOD would overwrite any filters on the table and you'd get a correct result. But this does not happen. What happens is that Power BI makes an intersection of the year selected with the 6M period you're trying to calculate the measure over. Hence I know that you don't have a proper Date table. I've been in this business for much too long not to be able to recognize at first sight that a date table is not in there...

Easy 🙂

Best
D

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.