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
Lavanya_PowerBI
New Member

Repeat Index number after every 4 rows

Here is the sample data.Dataset is group by ID,Sorted by ID,week start date. Is it possible to repeat the index number after every 4  rows. 

 

I am expecting to see 1,2,3,4,1,2,3,4,1,2,3,4 etc as my index number 

 

Lavanya_PowerBI_0-1708885355311.png

 

 

 

 

1 ACCEPTED SOLUTION
Jonvoge
Super User
Super User

Hi Lavanya.

 

I'm not sure exactly how to solve this the most efficient way, but I believe you may be able to get close using some of the following:

Create a Custom Column 'DivideByFour', Where you divide your current Index column by 4.

Create a new Custom Column, 'ResetRows': If [DivideByFour] / [DivideByFour] = 1 then [DivideByFour] else null.

Use a fill action on your ResetRows column to fill out the empty rows, effectively grouping your rows into groups of four rows.

Finally, follow othis guide (or find another similar via Google) to create an Index which resets every time your ResetRows group value changes: PowerQuery - Index Column That Restarts Based on a Grouped Column (devcodef1.com)

_____________________________________________________
I hope my comment was helpful.
If your question was answered, please mark your post as 'Solved' and consider giving me a 'Thumbs Up'.

View solution in original post

3 REPLIES 3
Jonvoge
Super User
Super User

Hi Lavanya.

 

I'm not sure exactly how to solve this the most efficient way, but I believe you may be able to get close using some of the following:

Create a Custom Column 'DivideByFour', Where you divide your current Index column by 4.

Create a new Custom Column, 'ResetRows': If [DivideByFour] / [DivideByFour] = 1 then [DivideByFour] else null.

Use a fill action on your ResetRows column to fill out the empty rows, effectively grouping your rows into groups of four rows.

Finally, follow othis guide (or find another similar via Google) to create an Index which resets every time your ResetRows group value changes: PowerQuery - Index Column That Restarts Based on a Grouped Column (devcodef1.com)

_____________________________________________________
I hope my comment was helpful.
If your question was answered, please mark your post as 'Solved' and consider giving me a 'Thumbs Up'.

Thanks for the idea. I tried something similar and I got the desired results .I started a column index from 0 and usd  below 

= Table.AddColumn(#"Added Index", "Custom", each Number.Mod([Index],4) + 1)

 

Thanks again!

Lavanya_PowerBI
New Member

Lavanya_PowerBI_0-1708890197599.png

 

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 Kudoed Authors