Forum Discussion
gvg
6 years agoPost Prodigy
Dynamic source table name in Power Query
Hi,
I have two data sources as tables in my query list: tableA and tableB. I want to build another query (myQuery) that dynamically takes either tableA or tableB as source. I know how to use parameters, but my problem is that I can not figure out how to specify the variable part (A or B) in my Source instruction in myQuery in "M". Tried this one, but it doesn't seem to work:
Source="table" & parameter1 // parameter1 is ="A" or "B"
Can anybody help?
Source = Expression.Evaluate("Table" & parameter, #shared)
13 Replies
- avatorlImpactful Individual
= if your_parameter="A" then TableA else if your_parameter="B" then TableB else nullyou can use simple if statement