Share via

Excel Power Query, M code to add calculated quantity of Rows to a table

Anonymous
2022-10-04T18:12:51+00:00

Could not locate the best place to post this... perhaps you can point me to right spot?

I have the follow code snippet I am using in my Power Query.

It adds the quantity of rows I need today. But tomorrow and beyond, the quantity may very well change. I can calculate the quantity I need, and could perhaps fashion a far from eloquent repetitive condition statements, but I've not got a clue on how to code this so that result is always the needed quantity.

In the case I did below, I needed 72 records relating to "AEC Collection". Then after a few days the data source came in with a new record, but I didn't notice. I had to edit the M Code to remove one row. Surely there is a way to code this. In other programing languages, I would have used loop until the quantity was 72, but it appears in Power Query there is not a way to write a loop until.

WithNewRows = Table.InsertRows(SetToAECCol,50,{

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 51], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 52], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 53], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 54], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 55], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 56], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 57], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 58], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 59], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 60], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 61], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 62], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 63], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 64], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 65], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 66], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 67], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 68], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 69], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 70], 

                                                  [UserName="ITOpenSeat",Product Family="AEC Collection", Index= 71] 

                                                } 

                              ),
Microsoft 365 and Office | Excel | For business | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2022-10-05T06:49:41+00:00

    Dear M3dHutch,

    Greetings! Thank you for posting in the Microsoft forum.

    Based on your post, I found a similar post where members are discussing the same scenario, please check the link below, see if this helps:

    Loop Command in Power Query - Microsoft Tech Community

    If you still need help, please check the Support and troubleshooting section of the support article to get help with the Power Query.

    At the same time, we will also keep this thread open, so other Community members and Experts can also share their suggestions and inputs.

    Thank you for your cooperation and understanding!

    With sincerest regards,

    Neha Singh | Microsoft Community Moderator

    Was this answer helpful?

    0 comments No comments