Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
JamesRobson
Resolver II
Resolver II

Dynamically Merge Tables Based on Parameter

Hi,

 

 I'm currently taking a PDF order sheet and 'converting' it into a standard format "PDFQuery1" then I merge that into "LoadQuery" that is checking our ERP system for stock, jobs, delvieries etc.

This works fine, so well in fact we now want to expand this to other customers (great!) however each PDF is in a different format so I have created "PDFQuery2" that will convert Customer B pdf into our standard format no problem.

 

Now in my issue is in "LoadQuery" I want to use a paramater, customer code that end user popualtes, to determine which "PDFQuery" to merge in...

 

Original step

= Table.NestedJoin(PDFQuery1, {"CustItemRef"}, PM_Item, {"CustItemRef"}, "PM_Item", JoinKind.LeftOuter)

Attempt 1

 - Add Cust Code

let
Source = Excel.CurrentWorkbook(){[Name="CustCode"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"CustCode", type text}}),
CustCode = #"Changed Type"{0}[CustCode]
in
CustCode

 

then use this to repalce the fixed query name

 

= Table.NestedJoin(CustCode, {"CustItemRef"}, PM_Item, {"CustItemRef"}, "PM_Item", JoinKind.LeftOuter)

however this errors

Expression.Error: We cannot convert the value "10264" to type Table.
Details:
Value=10264
Type=[Type]

 

** PDFQuery1 is actually named 10264 at this point

 

Now I have a work around which is merge all the "PDFQueries" then filter rows based on CustCode however it doesn't seem like a great solution 😞

Had a look elsewhere and only finding solutions for dynmaic columns but always from a fixed query/table so any help appreciated!

 

Thanks,

2 ACCEPTED SOLUTIONS
v-stephen-msft
Community Support
Community Support

Hi @JamesRobson ,

 

The dynamic table name might help you, please kindly refer to

Solved: Dynamic source table name in Power Query - Microsoft Power BI Community

Source = Expression.Evaluate("Table" & parameter, #shared)

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Thanks for the heads up. I haven't been able to get it working today but I'll keep going at it and try to work out where i'm gonig wrong and mark as resovled if/when i get there.

 

Funnily enough last night I went down the 'if' statement route as a slightly better workaround so good to see I wasn't the only person to try that 🙂

View solution in original post

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @JamesRobson ,

 

The dynamic table name might help you, please kindly refer to

Solved: Dynamic source table name in Power Query - Microsoft Power BI Community

Source = Expression.Evaluate("Table" & parameter, #shared)

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for the heads up. I haven't been able to get it working today but I'll keep going at it and try to work out where i'm gonig wrong and mark as resovled if/when i get there.

 

Funnily enough last night I went down the 'if' statement route as a slightly better workaround so good to see I wasn't the only person to try that 🙂

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors