Forum Discussion
Trend calculation dynamically
- 5 years ago
Hi, amirabedhiafi
According to your description, I think you can create another measure to display ‘the N weeks prior to the Last N weeks’, so you can use one slicer to get data from two different time periods.
Like this:
Last2NWeeks-LastNWeeks = VAR LastNWeeks = CALCULATE ( SUM ( 'COVID Data'[COVID Cases] ), FILTER ( ALL ( 'Date' ), 'Date'[Week Rank] >= MAX ( 'Date'[Week Rank] ) - WeekRank[WeekRank Value] && 'Date'[Week Rank] <= MAX ( 'Date'[Week Rank] ) ) ) VAR Last2NWeeks = CALCULATE ( SUM ( 'COVID Data'[COVID Cases] ), FILTER ( ALL ( 'Date' ), 'Date'[Week Rank] >= MAX ( 'Date'[Week Rank] ) - WeekRank[WeekRank Value] * 2 && 'Date'[Week Rank] <= MAX ( 'Date'[Week Rank] ) ) ) RETURN Last2NWeeks - LastNWeeksIf it doesn’t solve your problem, please feel free to ask me.
Best Regards
Janey Guo
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, amirabedhiafi
According to your description, I think you can create another measure to display ‘the N weeks prior to the Last N weeks’, so you can use one slicer to get data from two different time periods.
Like this:
Last2NWeeks-LastNWeeks =
VAR LastNWeeks =
CALCULATE (
SUM ( 'COVID Data'[COVID Cases] ),
FILTER (
ALL ( 'Date' ),
'Date'[Week Rank]
>= MAX ( 'Date'[Week Rank] ) - WeekRank[WeekRank Value]
&& 'Date'[Week Rank] <= MAX ( 'Date'[Week Rank] )
)
)
VAR Last2NWeeks =
CALCULATE (
SUM ( 'COVID Data'[COVID Cases] ),
FILTER (
ALL ( 'Date' ),
'Date'[Week Rank]
>= MAX ( 'Date'[Week Rank] ) - WeekRank[WeekRank Value] * 2
&& 'Date'[Week Rank] <= MAX ( 'Date'[Week Rank] )
)
)
RETURN
Last2NWeeks - LastNWeeksIf it doesn’t solve your problem, please feel free to ask me.
Best Regards
Janey Guo
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.