Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Count attempts between success, before success, average attempts between success.

Hello, Example data below

 

Im curious on how to count the number of "RepOuts" between the 1st success and the 2nd success, answer is 2. The data looks like this with different "ClassAccount" numbers and im looking to find an average number of "RepOut" between success. Or even how many "repout" before the 1st success. 

 

ClassAccountActionResultDateRepOutSuccess
503207139THVM3/21/202211
503207139THVM3/17/202210
503207139BV$N3/16/202200
503207139THVM3/16/202210
503207139RNMO2/17/202200
503207139RNMO1/17/202200
503207139CSSE1/14/202200
503207139RNMO1/14/202200
503207139THPN1/14/202211

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

I created some data:

vyangliumsft_0-1650344432845.png

Here are the steps you can follow:

1. In Power query. Add Column – Index Column – From 1.

vyangliumsft_1-1650344432847.png

2. Create calculated column.

Flag =
IF(
    'Table'[Success]=1&&'Table'[RepOut]=1,0,
    IF(
        'Table'[RepOut]=1&&'Table'[Success]=0,1,2))
IF =
IF(
    'Table'[Flag]=0,1,0)
group =
var _1=CALCULATE(SUM('Table'[IF]),FILTER(ALL('Table'),'Table'[ClassAccount]=EARLIER('Table'[ClassAccount])&&'Table'[Index]<EARLIER('Table'[Index])))
return
_1
failed attempts =
CALCULATE(COUNT('Table'[Flag]),FILTER(ALL('Table'),'Table'[ClassAccount]=EARLIER('Table'[ClassAccount])&&'Table'[group]=EARLIER('Table'[group])&&'Table'[Flag]=1))
the number of successes =
CALCULATE(COUNT('Table'[Flag]),FILTER(ALL('Table'),'Table'[ClassAccount]=EARLIER('Table'[ClassAccount])&&'Table'[group]=EARLIER('Table'[group])&&'Table'[Flag]=0))
average =
DIVIDE('Table'[failed attempts],'Table'[the number of successes])

3. Result:

vyangliumsft_2-1650344432850.png

Please click here for the pbix file

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi  @Anonymous ,

I created some data:

vyangliumsft_0-1650344432845.png

Here are the steps you can follow:

1. In Power query. Add Column – Index Column – From 1.

vyangliumsft_1-1650344432847.png

2. Create calculated column.

Flag =
IF(
    'Table'[Success]=1&&'Table'[RepOut]=1,0,
    IF(
        'Table'[RepOut]=1&&'Table'[Success]=0,1,2))
IF =
IF(
    'Table'[Flag]=0,1,0)
group =
var _1=CALCULATE(SUM('Table'[IF]),FILTER(ALL('Table'),'Table'[ClassAccount]=EARLIER('Table'[ClassAccount])&&'Table'[Index]<EARLIER('Table'[Index])))
return
_1
failed attempts =
CALCULATE(COUNT('Table'[Flag]),FILTER(ALL('Table'),'Table'[ClassAccount]=EARLIER('Table'[ClassAccount])&&'Table'[group]=EARLIER('Table'[group])&&'Table'[Flag]=1))
the number of successes =
CALCULATE(COUNT('Table'[Flag]),FILTER(ALL('Table'),'Table'[ClassAccount]=EARLIER('Table'[ClassAccount])&&'Table'[group]=EARLIER('Table'[group])&&'Table'[Flag]=0))
average =
DIVIDE('Table'[failed attempts],'Table'[the number of successes])

3. Result:

vyangliumsft_2-1650344432850.png

Please click here for the pbix file

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

tamerj1
Super User
Super User

@Anonymous 

Please try

 

Average Failed =
VAR Numerator =
    SUMX ( Table, IF ( Table[RepOut Success] = 0, 1, 0 ) )
VAR Denominator =
    SUM ( Table[RepOut Success] ) -1
RETURN
    DIVIDE ( Numerator, Denominator )

 

tamerj1
Super User
Super User

@Anonymous 

Can you please explain how the answer is 2?

Anonymous
Not applicable

In this case there are 2 rows where repout = 1 and success =0, which means 2 failed attempts. A successful attempt is repout=1 and success=1. Since those 2 failed attempts happened between the 1st success and the 2nd success, the answer is 2.

 

Im trying to find the average number of failed attempts to collected between successful attempts. 

@Anonymous 

And for each account there could be more than 2 two successful attempts?

Anonymous
Not applicable

Yes, this is just one example using 1 account with a short date range. The data has multiple accounts with multiple lines of failed attempts and successful attempts, im looking to find the average number of failed attempts between successful attempts, on the account level. 

I understand that but my question was about each account. There should be maximum of 2 successful attempts or is possible to have more than 2 successful attempts for each account. 
Also what would be the average? If the numerator is the number of attempts between successful attempts, what would be the numerator? 
how are you planning to display the result? On a card visual or on a table by account?

Anonymous
Not applicable

yes, its possible to have more than 2 successful atempts per account.

 

the average would be, Numerator = sum of the failed attempts between successes, divided by the denominator = number of gaps between successes? If i said that right, the denominator could also be the number of successes - 1 to remove the 1st success that didnt have a success prior to it. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.