Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
Consider following example:
Part | WeekNumber |
A | 1 |
A | 5 |
A | 4 |
A | 3 |
A | 11 |
A | 10 |
A | 15 |
A | 14 |
A | 16 |
There are 4 separate runs for part A which are (1), (3,4,5), (10,11), (14,15,16).
I need to have a measure which would output count of elements in the longest run, so in the example above this would be 3.
It does not matter if there is more than one equally long run, just need to display the highest number.
WeekNumber is not always sorted.
Thanks
Evan
Solved! Go to Solution.
Hi @Anonymous ,
Try the following calculated columns and measure:
Column =
IF(
'Table'[WeekNumber] = 1,
0,
'Table'[WeekNumber] - CALCULATE(
MAX('Table'[WeekNumber]),
FILTER('Table',
'Table'[Part] = EARLIER('Table'[Part])
&& 'Table'[WeekNumber] < EARLIER('Table'[WeekNumber])
)
)
)
GroupMin =
CALCULATE(
MAX('Table'[WeekNumber]),
FILTER(
'Table',
'Table'[Column] <> 1
&&'Table'[Part] = EARLIER('Table'[Part])
&& 'Table'[WeekNumber] <= EARLIER('Table'[WeekNumber])
)
)
Measure =
MAXX(
'Table',
CALCULATE(
DISTINCTCOUNT('Table'[WeekNumber]),
ALLEXCEPT(
'Table',
'Table'[Part],
'Table'[GroupMin]
)
)
)
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Try the following calculated columns and measure:
Column =
IF(
'Table'[WeekNumber] = 1,
0,
'Table'[WeekNumber] - CALCULATE(
MAX('Table'[WeekNumber]),
FILTER('Table',
'Table'[Part] = EARLIER('Table'[Part])
&& 'Table'[WeekNumber] < EARLIER('Table'[WeekNumber])
)
)
)
GroupMin =
CALCULATE(
MAX('Table'[WeekNumber]),
FILTER(
'Table',
'Table'[Column] <> 1
&&'Table'[Part] = EARLIER('Table'[Part])
&& 'Table'[WeekNumber] <= EARLIER('Table'[WeekNumber])
)
)
Measure =
MAXX(
'Table',
CALCULATE(
DISTINCTCOUNT('Table'[WeekNumber]),
ALLEXCEPT(
'Table',
'Table'[Part],
'Table'[GroupMin]
)
)
)
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , continuous streak problem
Refer if old solution can help
https://community.powerbi.com/t5/Desktop/Need-help-in-DAX/m-p/1277302#M559393
My attempt
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
61 | |
61 | |
55 | |
38 | |
27 |
User | Count |
---|---|
86 | |
61 | |
45 | |
41 | |
39 |