Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi community,
I have a semi complex problem I cant get my head around.
I have a measure which I want to restrict the visible data based on date selection. So if I select todays date then data until today is shown in line chart but if select a date 2 months ago, it only shows up to that date. I have it working for basic measures using the method on SQLBI ( show previous 6 months ) which I've adapted for my custom calendar (based on weeks).
Problem I have is if I try to apply to a measure that includes time based calculations, they all get removed too and breaks the result.
My dax code is:
Solved! Go to Solution.
Hi @dange187 ,
Based on the information you provided, you can follow these steps:
1.Add new measure.
(1)
Average =
VAR _value =
CALCULATE (
AVERAGE ( 'Table'[amount] ),
FILTER (
ALL ( 'Table' ),
[week] <= SELECTEDVALUE ( 'Table'[week] )
&& [week]
>= SELECTEDVALUE ( 'Table'[week] ) - 3
)
)
RETURN
IF ( SELECTEDVALUE ( 'Table'[week] ) < 4, BLANK (), _value )
(2)
4WeekAverage =
VAR _1 =
MAXX ( ALLSELECTED ( 'Table 2' ), 'Table 2'[week] )
RETURN
IF (
MAX ( 'Table'[week] ) >= ( _1 - 3 )
&& MAX ( 'Table'[week] ) <= _1,
[Average],
BLANK ()
)
Final output:
How to Get Your Question Answered Quickly - Microsoft Fabric Community
If it does not help, please provide more details with your desired out put and pbix file without privacy information.
Best Regards,
Ada Wang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @dange187 ,
Based on the information you provided, you can follow these steps:
1.Add new measure.
(1)
Average =
VAR _value =
CALCULATE (
AVERAGE ( 'Table'[amount] ),
FILTER (
ALL ( 'Table' ),
[week] <= SELECTEDVALUE ( 'Table'[week] )
&& [week]
>= SELECTEDVALUE ( 'Table'[week] ) - 3
)
)
RETURN
IF ( SELECTEDVALUE ( 'Table'[week] ) < 4, BLANK (), _value )
(2)
4WeekAverage =
VAR _1 =
MAXX ( ALLSELECTED ( 'Table 2' ), 'Table 2'[week] )
RETURN
IF (
MAX ( 'Table'[week] ) >= ( _1 - 3 )
&& MAX ( 'Table'[week] ) <= _1,
[Average],
BLANK ()
)
Final output:
How to Get Your Question Answered Quickly - Microsoft Fabric Community
If it does not help, please provide more details with your desired out put and pbix file without privacy information.
Best Regards,
Ada Wang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.