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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
knielson
Frequent Visitor

How to calculate a win/loss streak with matchup data?

I have some match data with home team and away teams and the outcome of the match. 

How in power BI can I flag the current win and loss streak at that current point in the season.

The grey columns are what I'm looking to create.

For example, Utah wins 3 matches in a row but loses their 4th, so their highest win streak is 3 and their current loss streak is 1. 

 

knielson_2-1664833527878.png

 

 

 

1 ACCEPTED SOLUTION

Hi, @knielson ;

Try it.

Current Win Streak = 
var _max=CALCULATE(MAX('Table'[natch_ id]),FILTER('Table',[LTeam]=EARLIER('Table'[WTeam])&&[natch_ id]<EARLIER('Table'[natch_ id])))

var _min=CALCULATE(MIN('Table'[natch_ id]),FILTER('Table',[WTeam]=EARLIER('Table'[WTeam])&&[natch_ id]<EARLIER('Table'[natch_ id])))
var _value=IF(_max>=_min,_max,_min)
var _res= CALCULATE(COUNT('Table'[WTeam]),FILTER('Table',[natch_ id]>=_value&&[natch_ id]<=EARLIER('Table'[natch_ id])&&[WTeam]=EARLIER('Table'[WTeam])))
return _res
Current Loss Streak = 
var _max=CALCULATE(MAX('Table'[natch_ id]),FILTER('Table',[WTeam]=EARLIER('Table'[LTeam])&&[natch_ id]<EARLIER('Table'[natch_ id])))

var _min=CALCULATE(MIN('Table'[natch_ id]),FILTER('Table',[LTeam]=EARLIER('Table'[LTeam])&&[natch_ id]<EARLIER('Table'[natch_ id])))
var _value=IF(_max>=_min,_max,_min)
var _res= CALCULATE(COUNT('Table'[LTeam]),FILTER('Table',[natch_ id]>=_value&&[natch_ id]<=EARLIER('Table'[natch_ id])&&[LTeam]=EARLIER('Table'[LTeam])))
return _res


Best Regards,
Community Support Team _ Yalan Wu
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

3 REPLIES 3
v-yalanwu-msft
Community Support
Community Support

Hi, @knielson ;

You could create a column by dax.

Current Win Streak = 
var _max=CALCULATE(MAX('Table'[natch_ id]),FILTER('Table',[LTeam]=EARLIER('Table'[WTeam])&&[natch_ id]<EARLIER('Table'[natch_ id])))

var _min=CALCULATE(MIN('Table'[natch_ id]),FILTER('Table',[WTeam]=EARLIER('Table'[WTeam])&&[natch_ id]<EARLIER('Table'[natch_ id])))
var _value=IF(_max>_min,_max,_min)
var _res= CALCULATE(COUNT('Table'[WTeam]),FILTER('Table',[natch_ id]>=_value&&[natch_ id]<=EARLIER('Table'[natch_ id])&&[WTeam]=EARLIER('Table'[WTeam])))
return _res
Current Loss Streak = 
var _max=CALCULATE(MAX('Table'[natch_ id]),FILTER('Table',[WTeam]=EARLIER('Table'[LTeam])&&[natch_ id]<EARLIER('Table'[natch_ id])))

var _min=CALCULATE(MIN('Table'[natch_ id]),FILTER('Table',[LTeam]=EARLIER('Table'[LTeam])&&[natch_ id]<EARLIER('Table'[natch_ id])))
var _value=IF(_max>_min,_max,_min)
var _res= CALCULATE(COUNT('Table'[LTeam]),FILTER('Table',[natch_ id]>=_value&&[natch_ id]<=EARLIER('Table'[natch_ id])&&[LTeam]=EARLIER('Table'[LTeam])))
return _res

The final show:

vyalanwumsft_0-1664850707442.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This is great. I noticed that it doesn't reset the streak in the event of a tie. How could that be done?

Hi, @knielson ;

Try it.

Current Win Streak = 
var _max=CALCULATE(MAX('Table'[natch_ id]),FILTER('Table',[LTeam]=EARLIER('Table'[WTeam])&&[natch_ id]<EARLIER('Table'[natch_ id])))

var _min=CALCULATE(MIN('Table'[natch_ id]),FILTER('Table',[WTeam]=EARLIER('Table'[WTeam])&&[natch_ id]<EARLIER('Table'[natch_ id])))
var _value=IF(_max>=_min,_max,_min)
var _res= CALCULATE(COUNT('Table'[WTeam]),FILTER('Table',[natch_ id]>=_value&&[natch_ id]<=EARLIER('Table'[natch_ id])&&[WTeam]=EARLIER('Table'[WTeam])))
return _res
Current Loss Streak = 
var _max=CALCULATE(MAX('Table'[natch_ id]),FILTER('Table',[WTeam]=EARLIER('Table'[LTeam])&&[natch_ id]<EARLIER('Table'[natch_ id])))

var _min=CALCULATE(MIN('Table'[natch_ id]),FILTER('Table',[LTeam]=EARLIER('Table'[LTeam])&&[natch_ id]<EARLIER('Table'[natch_ id])))
var _value=IF(_max>=_min,_max,_min)
var _res= CALCULATE(COUNT('Table'[LTeam]),FILTER('Table',[natch_ id]>=_value&&[natch_ id]<=EARLIER('Table'[natch_ id])&&[LTeam]=EARLIER('Table'[LTeam])))
return _res


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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