Forum Discussion
`HELP!
- 4 years ago
Without your pbix file, I made a simple table to demonstrate a DAX expression that shows one way to do this.
AgentTenureResult
Joe 1 8 Joe 8 9 Joe 15 9 Joe 22 8 Joe 29 9 Mary 1 9 Mary 8 9 Mary 15 7 Mary 22 9 Mary 29 7 Sally 1 9 Sally 8 8 Sally 15 9 Sally 22 9 Sally 29 9 FirstTenureTwoWeeksOver9 =
VAR summary =
ADDCOLUMNS (
SUMMARIZE ( Results, Results[Agent], Results[Tenure] ),
"cResults", CALCULATE ( SUM ( Results[Result] ) )
)
VAR withprevvalue =
ADDCOLUMNS (
summary,
"cPrevResult",
VAR thisagent = Results[Agent]
VAR thistenure = Results[Tenure]
RETURN
MINX (
FILTER (
summary,
Results[Agent] = thisagent
&& Results[Tenure] = thistenure - 7
),
[cResults]
)
)
VAR result =
MINX (
FILTER ( withprevvalue, [cResults] >= 9 && [cPrevResult] >= 9 ),
Results[Tenure]
)
RETURN
resultPat
Without your pbix file, I made a simple table to demonstrate a DAX expression that shows one way to do this.
AgentTenureResult
| Joe | 1 | 8 |
| Joe | 8 | 9 |
| Joe | 15 | 9 |
| Joe | 22 | 8 |
| Joe | 29 | 9 |
| Mary | 1 | 9 |
| Mary | 8 | 9 |
| Mary | 15 | 7 |
| Mary | 22 | 9 |
| Mary | 29 | 7 |
| Sally | 1 | 9 |
| Sally | 8 | 8 |
| Sally | 15 | 9 |
| Sally | 22 | 9 |
| Sally | 29 | 9 |
FirstTenureTwoWeeksOver9 =
VAR summary =
ADDCOLUMNS (
SUMMARIZE ( Results, Results[Agent], Results[Tenure] ),
"cResults", CALCULATE ( SUM ( Results[Result] ) )
)
VAR withprevvalue =
ADDCOLUMNS (
summary,
"cPrevResult",
VAR thisagent = Results[Agent]
VAR thistenure = Results[Tenure]
RETURN
MINX (
FILTER (
summary,
Results[Agent] = thisagent
&& Results[Tenure] = thistenure - 7
),
[cResults]
)
)
VAR result =
MINX (
FILTER ( withprevvalue, [cResults] >= 9 && [cPrevResult] >= 9 ),
Results[Tenure]
)
RETURN
result
Pat
- Anonymous4 years agoNot applicable