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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Pan_Forex
Helper III
Helper III

Winstreak and losestreak

Hi guys! I counted winstreak and losestreak for each player. I don't know why but some people have 5 winstreaks in a row and 1 loss at the same time which is impossible. My tabel: 

 
 

asdasd.jpg

woncol = RANKX(FILTER(ALL('table'),'table'[player]=earlier('table'[player])),'public players'[id],,ASC,Dense)
flag = IF('table'[won]= FALSE(), 0, 1)
minflag =
CALCULATE (
   MIN ( 'table'[woncol] ),
    FILTER (
        ALL ( 'table' ),
        'public players'[woncol] >= EARLIER ( 'table'[woncol] )
        &&'table'[player]=EARLIER('table'[player])
            && 'table'[won] = FALSE()
)
)
 
Actual Winstreak =
VAR _1 =
    CALCULATE (
        COUNT( 'table'[flag] ),
        FILTER (
            ALL ( 'table' ),
           
                 'table'[minflagdate] = SELECTEDVALUE ( 'table'[minflag] )
                && 'table'[player]=SELECTEDVALUE('table'[player] )
                &&'table'[flag]=1
        )
    )
RETURN
   _1
 
For losestreak I counted everything the same only "flag" changed to false. Almost everything is counted improvement. Any ideas why some players have winstreak and losestreak at the same time? 
sdsdsddd.png
1 ACCEPTED SOLUTION

@Pan_Forex Not certain this is what you are looking for but you could try this (see below). You could combine this with a measure that is simply MAX('Table'[Win Streak Column])

Win Streak Column = 
    VAR __Player = [player]
    VAR __id = [id]
    VAR __Table = FILTER(ALL('Table'),[player] = __Player && [id] <= __id)
    VAR __Loss = MAXX(FILTER(__Table,[won] = FALSE()),[id])
    VAR __Result = IF(__Loss = BLANK(),COUNTROWS(__Table),COUNTROWS(FILTER(__Table, [id] > __Loss)))
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Greg_Deckler
Community Champion
Community Champion

@Pan_Forex Can you post your sample data as text? Sounds very similar to Cthulhu. Cthulhu - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Sorry, there is a pbix file with the whole table in the link: https://we.tl/t-4sJj8zcENK

Sorry, already correcting it 🙂

playeridwonflagminflagwoncol
CmXuTNsOTsmsiFBnPvjVHsXKrT71299True1145142
CMuVdfxDLzKisPtIxmyLxiWrcK71299True1265260
wpsBViXSSZXtCQSgVhobvcWnW71299False0131131
qPInEuDBbHaRKJzpFeIzoWXfg71299False08989
BGkrFysZHxcdxGIVxEEBPzETWB71299True121
BLbgUfRQguMPWFqbvltVMRyvLo71299False03535
CeqRurzZyuIZQAfDkovsdTyfSE71299False02828
CnvQSYdVAJNYaQYJBJxJemHhS71299False011
oaxLIcZnZWHfMydgZNlCdbty71299True15856
wHouTwXYLGcMnxtNKNUAWUdeu71258False0125125
BbamEvAlDaFJIXOpCSvRGXFrrR71258True16160
kYinRhrIqgJFFOgUUcbLvlzBp71258True17876
CWKAuYIXqUGewnxVoKOQDFNmFD71258True18786
CmXuTNsOTsmsiFBnPvjVHsXKrT71258True1145141
BGqrNyICmavhBuWEMqgtcEJUoG71258False0145145
BZsMiHuibMqWQMrEydfExEJNHD71258False05959
McKRpmzqAifPaQRUFAvnUOSmk71258False03131
CWKAuYIXqUGewnxVoKOQDFNmFD71238False08585
CClLMBwNZpcAsqmxtzANnpdcQz71238True15149
BbamEvAlDaFJIXOpCSvRGXFrrR71238True16159
CeqRurzZyuIZQAfDkovsdTyfSE71238True12827
CmXuTNsOTsmsiFBnPvjVHsXKrT71238True1145140
BlePEpyRbwNZnIyQruGzrYKpQh71238True1149146
CUHzIOGDNIvSSdRaJObuFafAKI71238True14543
wHouTwXYLGcMnxtNKNUAWUdeu71238False0124124
BxyNvbdEMEKGgjhdAviDfbcNMB71238False06868
McKRpmzqAifPaQRUFAvnUOSmk71238False03030
BFiyegijChyTUSuWHWymXEbddj71238False07070
BZsMiHuibMqWQMrEydfExEJNHD71238False05858
WxpXBIdxIOMnWGqwBgBnvCrbt71210False066
BbamEvAlDaFJIXOpCSvRGXFrrR71210True16158
McKRpmzqAifPaQRUFAvnUOSmk71210True13029
xYeogVArlCXIwphrQIHvaPdr71210True18382
CdroilYGeReIUxBowVOyAjRcmf71210True1115112
BJhwYKuoyivSsZSJoknEWsUhaj71210True1116115
ClRuaVgEnHWxbcNmtgTSMelizc71210True1188187
pVypnhtdAtvonajbXAhFrOlTR71210False0214214
BlePEpyRbwNZnIyQruGzrYKpQh71210False0145145
CgcBpkSRXhTDKONAOnXnEMiBUX71210False04343
BZsMiHuibMqWQMrEydfExEJNHD71210False05757
ZgZniYcgXRJGTlxFcdgYQilip71210False044
CeqRurzZyuIZQAfDkovsdTyfSE71185False02626
wHouTwXYLGcMnxtNKNUAWUdeu71185True1124123
oaxLIcZnZWHfMydgZNlCdbty71185True15855
CmXuTNsOTsmsiFBnPvjVHsXKrT71185True1145139
AWRBkwydVvyprddKLiGSOWnBu71185False0130130
CClLMBwNZpcAsqmxtzANnpdcQz71185True15148
BFiyegijChyTUSuWHWymXEbddj71185False06969
qaHhhMuePZpHoEzJesKDxnsFk71185False03939
CozIhMpsYNyHIRplaWHZPUmCFe71185False05151
BOjJZjEwLutnSLwSiUWBtSMguS71185True121
CgcBpkSRXhTDKONAOnXnEMiBUX71111False04242
BvCSeeIdgqntLZYiCgtFUbeRXc71111True1 3
CjEkXqDbooVQBViOblFwHUJWTW71111True186
BIvZifBrQczctPGfXCzNDcsFjE71111True15453
xYeogVArlCXIwphrQIHvaPdr71111True18381
CXBhFVOjGfnVJFNdzMufDJzRW71111True1156154
BlePEpyRbwNZnIyQruGzrYKpQh71111False0144144
BoeGzypZvxDZHKMSGXydYOkQki71111False01111
CeqRurzZyuIZQAfDkovsdTyfSE71111False02525
xDetFXBJFKjnYKftlBfxcGdaJ71111False04242
BTMVGyfMBhiSUijJkeEikGtqoX71065True1161159
BlePEpyRbwNZnIyQruGzrYKpQh71065True1144143
BpDwEbgochrQINStyTcCmgrtsu71065False0208208
rQHjbRucPloxzhrAJJVXqhxvS71065False0130130
eKuYDDRHUVFPnJGmPpTgUhECN71065False06767
WBvhxhUpkoapgdRXQIdlwbYsh71065False088
BUWSmAGUOlFCCtgRZCvfCAwPiX71065True18885
CjEkXqDbooVQBViOblFwHUJWTW71065True185
BbamEvAlDaFJIXOpCSvRGXFrrR71059False05757
BMBWqEeLJXWDVFnChXaYkXdbSu71059False02323
xDetFXBJFKjnYKftlBfxcGdaJ71059True14241
XzpVlpdZcSInwzeSHIOkRomeP71059True16160
wpsBViXSSZXtCQSgVhobvcWnW71059True1131130
qPInEuDBbHaRKJzpFeIzoWXfg71059True18988
IKyIsKztvPPcdWcAHaLRCQOxh71059True1212211
CWKAuYIXqUGewnxVoKOQDFNmFD71059False08484
BgkPZMaMuuMwiXXwvTIwLySBmV71059False03333
CGTkqXhGqtLHMgPyUMmVklqYgQ71059False04242

@Pan_Forex Not certain this is what you are looking for but you could try this (see below). You could combine this with a measure that is simply MAX('Table'[Win Streak Column])

Win Streak Column = 
    VAR __Player = [player]
    VAR __id = [id]
    VAR __Table = FILTER(ALL('Table'),[player] = __Player && [id] <= __id)
    VAR __Loss = MAXX(FILTER(__Table,[won] = FALSE()),[id])
    VAR __Result = IF(__Loss = BLANK(),COUNTROWS(__Table),COUNTROWS(FILTER(__Table, [id] > __Loss)))
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hello @Greg_Deckler, Thank you very much for your time. Are you sure the function is correct? Unfortunately it displays me an error that the syntax is not correct.

@Pan_Forex It's correct in my PBIX attached below signature. So, pretty sure.

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.