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
Pan_Forex
Helper III
Helper III

Winstrike

Hello guys, I have no idea how to count winstrike. I have two columns, user and won (true or false). I would like to count the longest winning streak for each user and the actual.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Pan_Forex ,

I have created a simple smaple, please refer to it to see if it helps you.

Create columns.

flag = 
IF ( 'Table'[won] =FALSE(), 0,1 )
minflagdate = 
CALCULATE (
    MIN ( 'Table'[woncol] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[woncol] >= EARLIER ( 'Table'[woncol] )
        &&'Table'[user]=EARLIER('Table'[user])
            && 'Table'[won] = FALSE()
    )
)
woncol = RANKX(FILTER(ALL('Table'),'Table'[user]=earlier('Table'[user])),'Table'[index],,ASC,Dense)

Then create measures.

MM = 
VAR _1 =
    CALCULATE (
        COUNT( 'Table'[flag] ),
        FILTER (
            ALL ( 'Table' ),
            
                 'Table'[minflagdate] = SELECTEDVALUE ( 'Table'[minflagdate] )
                && 'Table'[user]=SELECTEDVALUE('Table'[user] )
                &&'Table'[flag]=1
        )
    )
RETURN
   _1
Measure = MAXX(FILTER(ALL('Table'),'Table'[user]=SELECTEDVALUE('Table'[user])),[MM])
Measure 2 = RANKX(ALL('Table'),CALCULATE([Measure]),,DESC,Skip)

Finally filter the measure 2 is 1.

vpollymsft_0-1670466714744.png

vpollymsft_1-1670466725221.png

Best Regards
Community Support Team _ Polly

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

4 REPLIES 4
Pan_Forex
Helper III
Helper III

Hi  @Anonymous  thank you very much for your time! Unfortunately, I did not specify that users are not in sequence and it's not working in my case. Below I add what a piece of the table looks like:

userwonindex
Atrue20
Btrue19
Cfalse18
Btrue17
Afalse16
Cfalse15
Cfalse14
Atrue13
Atrue12
Dtrue11
Efalse10
Etrue9
Etrue8
Atrue7
Ctrue6
Ctrue5
Afalse4
Afalse3
Etrue2
Efalse1

In my case, users A and E have the highest winstrike and it is 3

Anonymous
Not applicable

Hi @Pan_Forex ,

I have created a simple smaple, please refer to it to see if it helps you.

Create columns.

flag = 
IF ( 'Table'[won] =FALSE(), 0,1 )
minflagdate = 
CALCULATE (
    MIN ( 'Table'[woncol] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[woncol] >= EARLIER ( 'Table'[woncol] )
        &&'Table'[user]=EARLIER('Table'[user])
            && 'Table'[won] = FALSE()
    )
)
woncol = RANKX(FILTER(ALL('Table'),'Table'[user]=earlier('Table'[user])),'Table'[index],,ASC,Dense)

Then create measures.

MM = 
VAR _1 =
    CALCULATE (
        COUNT( 'Table'[flag] ),
        FILTER (
            ALL ( 'Table' ),
            
                 'Table'[minflagdate] = SELECTEDVALUE ( 'Table'[minflagdate] )
                && 'Table'[user]=SELECTEDVALUE('Table'[user] )
                &&'Table'[flag]=1
        )
    )
RETURN
   _1
Measure = MAXX(FILTER(ALL('Table'),'Table'[user]=SELECTEDVALUE('Table'[user])),[MM])
Measure 2 = RANKX(ALL('Table'),CALCULATE([Measure]),,DESC,Skip)

Finally filter the measure 2 is 1.

vpollymsft_0-1670466714744.png

vpollymsft_1-1670466725221.png

Best Regards
Community Support Team _ Polly

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

Everything works perfectly, thank you very much for your time and great job 🙂

Anonymous
Not applicable

Hi @Pan_Forex ,

I have created a simple sample, please refer to it to see if it helps you.

Create columns.

flag = 
IF ( 'Table'[won] =FALSE(), 0,1 )
minflagdate = 
CALCULATE (
    MIN ( 'Table'[Index] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[Index] >= EARLIER ( 'Table'[Index] )
            && 'Table'[won] = FALSE()
    )
)

Then create measures.

MM = 
VAR _1 =
    CALCULATE (
        SUM( 'Table'[flag] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Index]<= SELECTEDVALUE ( 'Table'[Index])
                && 'Table'[minflagdate] = SELECTEDVALUE ( 'Table'[minflagdate] )
                && 'Table'[ user ] = SELECTEDVALUE ( 'Table'[ user ] )
        )
    )
RETURN
    IF ( MAX ( 'Table'[flag] ) = 0, 0, _1 )
Measure = MAXX(FILTER(ALL('Table'),'Table'[ user ]=SELECTEDVALUE('Table'[ user ])),[MM])

vpollymsft_0-1670391834260.png

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

 

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.