Forum Discussion
Connect to Excel File
- 5 years ago
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 CombineCopy 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