Forum Discussion

Remy320's avatar
Remy320
Regular Visitor
5 years ago

How to Expand all columns using loop ExpandTableColumn with a loop

Hello Power Bi expert,  🙂

 

this is my Excel table i would like to analyse with power bi(but first to transform with power query). I would like to expand all table at once time(Every week a new table will be added, so next week a Week45_2020 will be created) 

Here is the code related to the table, i charge a Onedrive file which is supplied by a power automate connected will my server exchange to download files from my emails. then remove some columns and remains the date and rows with datas i need to analyse. 

I can do it manually but it's really annoying and not very useful if i need to go back to my file every week to expand all.

 

The Table Function "Table.expandTableColumn" take as argument the main table(here is headers from the previous step), the column name and the new name. 

Then i would like to make this week44_2020 dynamic, like a loop which can go through a list of my first column which contain all the worksheet name. For now it's a list and the function is only accepting column text value so i didn't make it to expand all this thing the dynamic way. Or maybe with a each function, i'm not that familiar with this function. 

 

 I'm just an manufacturing engineer without so much software background and new in Power Bi and m language area so i'm not so familiar how to do this. That's why i ask help here. 

 

Could anyone advise on  how to solve this problem ?

 

I already look for it for 4days without any results. I also checked these website and tried to adapt their code without success.

https://community.powerbi.com/t5/Desktop/Expanding-Multiple-Data-Tables-with-Unknown-Column-Names/m-p/471874

https://blog.crossjoin.co.uk/2014/05/21/expanding-all-columns-in-a-table-in-power-query/

https://bielite.com/blog/dynamically-expand-all-columns/

 

(The second one is making a giant loop of many gigabite until my computer crash)

 

Thank you very much in advance.

 

Best regards 

Rémy

 

4 Replies