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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h
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
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors