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

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.

Reply
Dicken
Responsive Resident
Responsive Resident

Adding Recuring Index

Hi, 

is it possibel to replacate ; 

 

QUOTIENT(SEQUENCE(25,1,0,1),3)+1  in power Query without first addin an actual index ;  

so I've got ; 

Table.TransformColumns(
Table.AddIndexColumn(Source, "Index", 0,
1), { "Index", each Number.IntegerDivide(_, 3 ) + 1 } )

 but you can put  1 /3 as the increment for index but not  Int div  which = 0 ?    and rounding does not seem to work either  . 

If it can't be done I can stop trying. 

Richard 


 

1 ACCEPTED SOLUTION

AFAIK, you can't do to directly get your desired output. But you could do something like:

= Table.AddIndexColumn(Source, "Index", 2/3,1/3) 

or

= Table.AddIndexColumn(Source, "Index", 2/3,1/3, Int64.Type)

 

and then, at the next step, change the data type to Int64.Type (whole number).

 

I would have thought is would do the conversion in the same step, but it does not.

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

Why start the index at 0 and add the +1 when you could start at one and not add anything?

 

--Nate

If you start the Index at 1, but then integer/divide by 3, your result is not as desired. Note that it starts with "0,0,1" instead of the desired "1,1,1"

 

ronrsnfld_0-1731502390901.png

 

 

 

Omid_Motamedise
Super User
Super User

You can apply both in one step of adding an index column, and you have to do it into two steps


If my answer helped solve your issue, please consider marking it as the accepted solution.
ronrsnfld
Super User
Super User

Not sure exactly what you want.

To create the same sequence (List) of values you can use the List.Accumulate function

List.Accumulate(
   {0..24},
   {},
   (s,c)=>s & {Number.IntegerDivide(c,3)+1})

 

ronrsnfld_0-1731440121228.png

 

If you want something else, please be more specific.

 

Dicken
Responsive Resident
Responsive Resident

Yes also used 

= let alist = {0..Table.RowCount( Source)-1 } ,
index = List.Transform( alist, (x)=>
Number.IntegerDivide( x, 3 ) + 1 ) in index 

and then Table from / to columns , to get  result. 
I was more interested in if there was a way to manipulate add index 

AFAIK, you can't do to directly get your desired output. But you could do something like:

= Table.AddIndexColumn(Source, "Index", 2/3,1/3) 

or

= Table.AddIndexColumn(Source, "Index", 2/3,1/3, Int64.Type)

 

and then, at the next step, change the data type to Int64.Type (whole number).

 

I would have thought is would do the conversion in the same step, but it does not.

Dicken
Responsive Resident
Responsive Resident

Thats pretty good,  I can't remember what it was but had a different situation, where I had 
to do a  transformation and THEN apply the data type as here. 
I'll mark this closed. 

Fowmy
Super User
Super User

@Dicken 

Add index first then transform:

Fowmy_0-1731437533093.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Dicken
Responsive Resident
Responsive Resident

Thanks I'll leave it open, never knwo someone might have ideas.  I'm still not sure why 
and increment of 1/3 works but Number.IntegerDivide( 1,3) just results in zero's. 

Greg_Deckler
Community Champion
Community Champion

@Dicken I don't believe so, no. You can add the Index column, then add your calculated column and then remove the Index column.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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