Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
I have this table that has the information about the result of an event that can be "Won" and "Lost".
I would like a measure in DAX that calculates the number of consecutive times that "Won" is achieved without "Lost" appearing.
In this example it would be 4
Result |
Won |
Won |
Lost |
Won |
Lost |
Won |
Won |
Won |
Won |
Lost |
Lost |
Solved! Go to Solution.
Hi @Matthew9900 ,
I suggest you to add an index column and then add a group column in Power Query Editor.
List.Count(
let
_Index = [Index]
in
Table.SelectRows(#"Added Index",each [Index]<=_Index and [Result] = "Lost")[Result])
New Table:
Measure:
Consecutive win times =
VAR _SUMMARIZE =
SUMMARIZE (
FILTER ( 'Table', 'Table'[Result] = "Won" ),
'Table'[Group],
"Count", COUNT ( 'Table'[Index] )
)
RETURN
MAXX ( _SUMMARIZE, [Count] )
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Matthew9900
The solution given by @Anonymous is great.
You can also do the 1st step with DAX as follows -create a Group COLUMN
Hi @Matthew9900 ,
I suggest you to add an index column and then add a group column in Power Query Editor.
List.Count(
let
_Index = [Index]
in
Table.SelectRows(#"Added Index",each [Index]<=_Index and [Result] = "Lost")[Result])
New Table:
Measure:
Consecutive win times =
VAR _SUMMARIZE =
SUMMARIZE (
FILTER ( 'Table', 'Table'[Result] = "Won" ),
'Table'[Group],
"Count", COUNT ( 'Table'[Index] )
)
RETURN
MAXX ( _SUMMARIZE, [Count] )
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
https://1drv.ms/u/s!AiUZ0Ws7G26Rhxiw0R7SH-9Yuurj?e=cK4yaP
Please check https://community.powerbi.com/t5/DAX-Commands-and-Tips/DAX-How-to-Count-the-Consecutive-Occurrences/...
I also tried it with this DAX function (hopefully easier)
Step1
Regards,
Ritesh
Thank you very much ribisht17
The solution is working but it is not adequate. The objective of this measurement is to find the longest winning streak, in this example it is giving me 6, but the correct answer should be 4.
That part is there in the link that I shared with you
Regards,
Ritesh