Increment Variable in Power Query

alsdkjfladjfgj12321

New Member
Joined
Jun 20, 2019
Messages
7
I am using VBA to make connections in Power Query, put a file name + extension in a cell, and rename the cell (Query1, Query2, Query3....). The macro runs fine. The part that I can't figure out is how to increment the variable in Power Query. It remains Query1 for connections that are made. It is hard coded in. I want to run the VBA be able to have the M code in each connection have Query1, then loop again to get Query2.

I hope what I described is clear.
 

Attachments

  • Power QUERY.JPG
    Power QUERY.JPG
    58.6 KB · Views: 23
  • Power Query2.JPG
    Power Query2.JPG
    53.8 KB · Views: 22

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Create a parameter query to enable a variable. Here is a link that will get you in the right direction.


There are others out there you may wish to google which are a bit more efficient, but this one will get you on the right track.
 
Upvote 0
Maybe this video will help you to understand what I believe you are trying to do. If this is not the case, then I urge you to post back with more explicit explanation of what you are attempting . By the way, sometimes guessing that it will or won't work will not get you a solution. Trying it sometimes gets you what you want. In the words of that great British poet. "If you try sometimes, you just might get what you need."

 
Upvote 0
I am having multiple querys connected to an excel file. Those connections will combined into a large table. The issue that I have is that when I run my macro it hard codes come of the data like the location of file. I set up so I have the file name as a query.

What I have now is a variable so part of the file path changes if the folder is moved. The file name can change from one connection to another. I tried to make a list of the file names and have the cell names changed as an attempt, but can't seem to figure out how to have one connection have a variable of Query1, and the next be Query2 to pull from the cell.
There may be a better way of linking it to power query, but this way made sense.
 

Attachments

  • Power Query3.JPG
    Power Query3.JPG
    119.9 KB · Views: 8
  • Power Query4.JPG
    Power Query4.JPG
    100.3 KB · Views: 7
  • Power Query5.JPG
    Power Query5.JPG
    108.1 KB · Views: 6
  • Power Query6.JPG
    Power Query6.JPG
    48 KB · Views: 8
  • Power Query7.JPG
    Power Query7.JPG
    76.5 KB · Views: 7
  • Power Query8.JPG
    Power Query8.JPG
    58.9 KB · Views: 8
  • Power Query9.JPG
    Power Query9.JPG
    41.4 KB · Views: 7
  • Power Query10.JPG
    Power Query10.JPG
    16 KB · Views: 6
  • Power Query11.JPG
    Power Query11.JPG
    73.4 KB · Views: 7
Upvote 0
I am lost by your explanation. I have provided you with two ways to create parameter queries. If this is something you are unable to understand and apply or grasp, then I have nothing further to offer you. Good Luck with finding your way on this issue.
 
Upvote 0
Maybe you need to look at the problem a different way. You seem to be importing the data from csv files. Have you tried placing all these files in a folder then using Import from folder rather than trying to bring them each in as separate queries then appending them?
Peter
 
Upvote 0
Maybe you need to look at the problem a different way. You seem to be importing the data from csv files. Have you tried placing all these files in a folder then using Import from folder rather than trying to bring them each in as separate queries then appending them?
Peter
Would be able to append them if I do that?
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,747
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top