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
Anonymous
Not applicable

Restart count in column

I'm adding a column to a date table.  The column needs to count to 20 by rows and restart.

 

Example:

 

Year     Month     Day     BusPeriod

2013    06            13        15

2013    06            14        16

2013    06            15        17

2013    06            16        18

2013    06            17        19

2013    06            18        20

2013    06            19        1

2013    06            20        2

2013    06            21        3

2013    06            22        4

2013    06            23        5

 

 

Any suggestion on how to go about this or if this is even possible?

1 ACCEPTED SOLUTION
arify
Microsoft Employee
Microsoft Employee

You can add an index column, and then transform that column into something like: Number.Mod([Index] + 1, 20)

 

    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1),
    #"Calculated Factorial" = Table.TransformColumns(#"Added Index",{{"Index", (index) => Number.Mod(index, 20) + 1, type number}})
in
    #"Calculated Factorial"

View solution in original post

2 REPLIES 2
arify
Microsoft Employee
Microsoft Employee

You can add an index column, and then transform that column into something like: Number.Mod([Index] + 1, 20)

 

    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1),
    #"Calculated Factorial" = Table.TransformColumns(#"Added Index",{{"Index", (index) => Number.Mod(index, 20) + 1, type number}})
in
    #"Calculated Factorial"
Anonymous
Not applicable

Works like a charm, nice solution @arify!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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