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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Mic1979
Post Partisan
Post Partisan

Dynamic List.Repeat

Dear all,

 

I have the following set of data:

 

Mic1979_0-1747056104290.png

 

I used the following formula to get:

ColToMove = HeadersToShift,
MovedCol = List.Repeat({null},2)&ColToMove

Mic1979_1-1747056165018.png

 

I tried to make this change dynamic based on the values I get in the Column Rows To ShiftDown

ColToMove = HeadersToShift,
MovedCol = List.Repeat({null},Rows_To_ShiftDown)&ColToMove

 

But I got this error:

Expression.Error: We cannot convert a value of type Table to type Number.

 

Could you help?

Thanks.

1 ACCEPTED SOLUTION
Omid_Motamedise
Super User
Super User

because Rows_To_ShiftDown is a table, not a single number — but List.Repeat expects a number as its second argument (how many times to repeat).

 

maybe you can use the following formula instead

 

ShiftCount = Rows_To_ShiftDown{0}[YourColumnName],
MovedCol = List.Repeat({null}, ShiftCount) & ColToMove

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

View solution in original post

6 REPLIES 6
v-kathullac
Community Support
Community Support

Hi @Mic1979 ,

we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.

If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

Regards,

Chaithanya

Hello @v-kathullac 

sorry for the delay, I just had the opportunity to test the solution.

Accepted, many thanks for your great support.

Omid_Motamedise
Super User
Super User

because Rows_To_ShiftDown is a table, not a single number — but List.Repeat expects a number as its second argument (how many times to repeat).

 

maybe you can use the following formula instead

 

ShiftCount = Rows_To_ShiftDown{0}[YourColumnName],
MovedCol = List.Repeat({null}, ShiftCount) & ColToMove

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

Hello

How to start this repetition from the second element of the column and not from the first?

 

Thanks.

Mic1979
Post Partisan
Post Partisan

I did not get your answer.

 

I knew the reason, but I would like to understand how to fix the issue.

I am not so familiar with PQ unfortunately. 🙂

 

Thanks a lot.

ZhangKun
Super User
Super User

To just answer your question: the error is because Rows_To_ShiftDown is a table, not a number.

Perhaps you could complete your question to get better suggestions.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors