Forum Discussion
Calculate Number of Periods of Consecutive Increase/Decrease
- 7 years ago
Anonymous
Can we do it in 2 steps
First this supporting calculated column
EachMonthChange =
VAR Mymonth = [Month]
RETURN
IF (
[Score]
> CALCULATE (
MIN ( Table1[Score] ),
FILTER ( Table1, Table1[Month] = Mymonth - 1 && [Site] = EARLIER ( [Site] ) )
),
1,
-1
)
Then the desired one
Sustaining Change = VAR mychange = [EachMonthChange] VAR result = MINX ( TOPN ( 1, FILTER ( Table1, [Month] < EARLIER ( [Month] ) && [EachMonthChange] <> mychange && [Site] = EARLIER ( [Site] ) ), [Month], DESC ), [Month] ) RETURN ( [Month] - IF ( ISBLANK ( result ), 1, result ) ) * [EachMonthChange]
Anonymous
Can we do it in 2 steps
First this supporting calculated column
EachMonthChange =
VAR Mymonth = [Month]
RETURN
IF (
[Score]
> CALCULATE (
MIN ( Table1[Score] ),
FILTER ( Table1, Table1[Month] = Mymonth - 1 && [Site] = EARLIER ( [Site] ) )
),
1,
-1
)
Then the desired one
Sustaining Change =
VAR mychange = [EachMonthChange]
VAR result =
MINX (
TOPN (
1,
FILTER (
Table1,
[Month] < EARLIER ( [Month] )
&& [EachMonthChange] <> mychange
&& [Site] = EARLIER ( [Site] )
),
[Month], DESC
),
[Month]
)
RETURN
( [Month] - IF ( ISBLANK ( result ), 1, result ) ) * [EachMonthChange]
Hi,
I am really interested in this for an SPC chart when looking to plot runs of increases/decreases. However, I currently have more than just "Site" to filter to. I would also like to be able to slice on the following fields: Site, Specialty, POD.
Because my visuals and the SPC chart are driven by those slicers, is it possible to come up with a calculated measure for this?
For example, chart for Site A, all Specs, all POD's may show sequences of increases/decreases but slicing the the Spec to 130 and POD to 1st Attendance would need to re-calculate the sequences.
Also, I am not working with month numbers but MonthDateStart (01/01/2000, 01/02/2000 etc)