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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Danielecc
Helper II
Helper II

How to count colums with consecutive value

Hi Everyone,

 

I need to know how to count columns with consecutive value where the value is "CC", but I need the MAX, form example:

 

Lecturas.PNG

I need to count only in the columns NLxx and with values "CC" (find the max of consecutive).

I colored in red the cases that make the match form me and the result expected is a calculated column like the last red column in the image.

 

Thanks a lot for your help.

 

CS01202101_DNL01CS02202102_DNL02CS03202103_DNL03CS04202104_DNL04CS05202105_DNL05CS06202106_DNL06CS07202107_DNL07CS08202108_DNL08CS09202109_DNL09CS10202110_DNL10CS11202111_DNL11CS12202112_DNL12Expected
025-01-2021CC026-02-2021CC025-03-2021CC001-04-2000CC001-05-2000LN001-06-2000LN007-07-2021LN809-08-2021CC1808-09-2021CC2208-10-2021CC2709-11-2021CC3209-12-2021CC5
125-01-2021LN226-02-2021CC425-03-2021LN805-04-2021CC1010-05-2021CC2008-06-2021CC2808-07-2021CC3509-08-2021CC4508-09-2021CC5508-10-2021CC6309-11-2021LN7009-12-2021LN7
425-01-2021CC926-02-2021CC1825-03-2021CC2705-04-2021CC3510-05-2021CC6208-06-2021CC7708-07-2021CC10309-08-2021LN12408-09-2021LN14308-10-2021CC16009-11-2021CC18009-12-2021LN7

 

 

 

Best regards...

 

1 REPLY 1
Anonymous
Not applicable

Hi @Danielecc ,

It can only achieve ordinary counting, instead of  consecutive value.

Please have atry.

Create a column.

 

Column = 
var NL01_= IF('Table'[NL01]="CC",1,0)
var NL02_= IF('Table'[NL02]="CC",1,0)
var NL03_= IF('Table'[NL03]="CC",1,0)
var NL04_= IF('Table'[NL04]="CC",1,0)
var NL05_= IF('Table'[NL05]="CC",1,0)
var NL06_= IF('Table'[NL06]="CC",1,0)
var NL07_= IF('Table'[NL07]="CC",1,0)
var NL08_= IF('Table'[NL08]="CC",1,0)
var NL09_= IF('Table'[NL09]="CC",1,0)
var NL10_= IF('Table'[NL10]="CC",1,0)
var NL11_= IF('Table'[NL11]="CC",1,0)
var NL12_= IF('Table'[NL12]="CC",1,0)
var result=NL01_*1+NL02_*1+NL03_*1+NL04_*1+NL05_*1+NL06_*1+NL07_*1+NL08_*1+NL09_*1+NL10_*1+NL11_*1+NL12_*1
return result

 

11.JPG

 

 

DAX is for calculated columns, not calculated rows. I tried to pivot on your data, but couldn't get the look you wanted.

Please vote for the function.

https://ideas.powerbi.com/ideas/idea/?ideaid=01763e26-eb76-48df-9006-dfa3ca08d572

 

 

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors