Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello everyone
I started to use power bi, now i have one question, when i go to get data and then select excel file, and load it , it loads but it asks me which tables /sheets i need to load
what if my excel file is dynamic, like other people are adding tables/sheets, is there a way as in power query excel.currentworkbook function and it used to load all my sheets/tables automatically, i used to open my excel file ,then add blank query and write the formula excel.currentworkbook(), then it showed me all tables and loaded them automatically
is there a way in power bi to do same? like i dont want to manually select the tables
Solved! Go to Solution.
Hello @chahineatallah
you can use this code to get every data from your file as combined table. However you have a problem when your are using tables, because this data is read twice, one tome from the sheet and one time from table. To avoid this you would need to define a rule for your workbooks to work only with tables or sheets. In this scenario you can filter the source step on the column "kind" what kind of data source you are accepting in your process
let
Source = Excel.Workbook(File.Contents(YourFilePath), null, true),
#"Added Custom" = Table.AddColumn(Source, "ContentTable", each if [Kind]="Sheet" then Table.PromoteHeaders([Data]) else if [Kind]="Table" then [Data] else #table({""},{{""}})),
Combine=Table.Combine(#"Added Custom"[ContentTable])
in
Combine
Copy paste this code to the advanced editor in a new blank query to see how the solution works. You have to insert the complete path of your files however.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Hello @chahineatallah
you can use this code to get every data from your file as combined table. However you have a problem when your are using tables, because this data is read twice, one tome from the sheet and one time from table. To avoid this you would need to define a rule for your workbooks to work only with tables or sheets. In this scenario you can filter the source step on the column "kind" what kind of data source you are accepting in your process
let
Source = Excel.Workbook(File.Contents(YourFilePath), null, true),
#"Added Custom" = Table.AddColumn(Source, "ContentTable", each if [Kind]="Sheet" then Table.PromoteHeaders([Data]) else if [Kind]="Table" then [Data] else #table({""},{{""}})),
Combine=Table.Combine(#"Added Custom"[ContentTable])
in
Combine
Copy paste this code to the advanced editor in a new blank query to see how the solution works. You have to insert the complete path of your files however.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
thanks jimmy, what i did actually, i pressed on the source in power bi and it showed me all my tables /sheets, i dont like codes specially m code as its very case sensitive lol
and then i filtered what i needed
Hi @chahineatallah ,
this is only possible if you're going to return all the different elements in one query (it will basically use the from-folder-method then).
But if you want to create a single query for each Excel-element, then a dynamic approach is not possible.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries