The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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.
User | Count |
---|---|
16 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
8 | |
8 |