cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

Helper II

## `HELP!

Hi @Icey  or anyone, I badly need your help on this.

I'm trying to create a measure that will calculate tenure in days it took them to achieved the goal (the ones highlighted in green). But, the student need to get the passing rate (>= 90%) for at least two consecutive weeks.. Like for example, looking at the below tables, I only need to view (TTP column) the tenure in days of the second week(the first two weeks that they achieved the passing rate). Any help is greatly appreciated.

Passing Rates s/b >= 90%

Sample data: Sample data

Measures:

Transform data:

1 ACCEPTED SOLUTION
Employee

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 =
SUMMARIZE ( Results, Results[Agent], Results[Tenure] ),
"cResults"CALCULATE ( SUM ( Results[Result] ) )
)
VAR withprevvalue =
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

Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

@mahoneypa HoosierBI on YouTube

3 REPLIES 3
Employee

Not sure what you mean.  Just the simple average is AVERAGE(Results[Tenure])

Pat

Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

@mahoneypa HoosierBI on YouTube

Employee

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 =
SUMMARIZE ( Results, Results[Agent], Results[Tenure] ),
"cResults"CALCULATE ( SUM ( Results[Result] ) )
)
VAR withprevvalue =
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

Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

@mahoneypa HoosierBI on YouTube

Helper II

Hi @mahoneypat ,
Quick question, how can you get the average of the column tenure?

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors