0
votes

I've got a power query that returns a dynamic number of columns.

If I step through the following steps.

  1. Refresh the query which generates a table with 13 columns

  2. Refresh the query which generates a table with 8 columns

I find that the table generated in Excel has the 8 columns I expect, plus 5 entirely blank columns left over from the first refresh. I have tried a number of steps including changing the connection settings and the table properties. If possible I'd like to avoid VBA.

Does anyone have any suggestions?

EDIT: This behaviour can be replicated by adding additional columns on any query, I believe, and then pressing refresh. In my scenario they are just leftover from the query previously returning more columns.

enter image description here

1
Can you post the Power M Code?virtualdvid
It's really simple - it's basically just call an SQL data base and pivot one of the columns (which leaves a dynamic number of columns)Stu-co
I would like to have a better idea about of what's going on. Can you post a screenshot with an example of your problem?virtualdvid
I've added a screenshot for clarity now!Stu-co

1 Answers

0
votes

Between your step 1 & 2, I would right-click the Query in the Workbook Queries pane and choose Load To / Only Create Connection. That will delete the entire Excel table.

Then right-click the Query again and choose Load To / Table / Existing worksheet.