SOLVED

Is it possible to retrieve data from parameter table and pass into Query?

%3CLINGO-SUB%20id%3D%22lingo-sub-327715%22%20slang%3D%22en-US%22%3EIs%20it%20possible%20to%20retrieve%20data%20from%20parameter%20table%20and%20pass%20into%20Query%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-327715%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20parameter%20table%20defined%20that%20allows%20the%20user%20to%20define%20the%20filtering%20values.%26nbsp%3B%20I%20would%20like%20to%20take%20the%20data%20they've%20inputted%20and%20pass%20that%20into%20my%20query%20call.%26nbsp%3B%20I%20currently%20have%20it%20set%20to%20filter%20after%20the%20source%20but%20due%20to%20the%20amount%20of%20data%2C%20it's%20quite%20slow.%26nbsp%3B%20I'm%20hoping%20to%20limit%20the%20data%20returned%20for%20efficiency.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIdeally%20I'd%20like%20to%20use%20my%20current%20getParameterValue%20call%20to%20define%20the%20extra%20statements%20that%20would%20be%20appended%20on%20to%20the%20query%20(source).%20Is%20this%20possible%3F%20If%20yes%2C%20how%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20was%20thinking%20it%20would%20be%20something%20like%20this%3A%3C%2FP%3E%3CP%3ESource%20%3D%20query%3C%2FP%3E%3CP%3E%23%22Filter%20A%22%20%3D%20query%20%2B%20'and%20fieldA%20%3D%20'%20%2B%20getParameterValue(FilterA)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-327715%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBI%20%26amp%3B%20Data%20Analytics%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPower%20Query%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-327805%22%20slang%3D%22en-US%22%3ERe%3A%20Is%20it%20possible%20to%20retrieve%20data%20from%20parameter%20table%20and%20pass%20into%20Query%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-327805%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20general%20yes.%20Implementation%20depends%20on%20what%20you%20query.%20You%20may%20add%20parameter%20directly%20into%20your%20query%20string%20and%2For%20take%20care%20about%20query%20folding%20to%20improve%20performance%20(for%20example%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fblog.crossjoin.co.uk%2F2017%2F06%2F11%2Fquery-folding-and-writing-your-own-sql-queries-in-power-querypower-biexcel-get-transform%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fblog.crossjoin.co.uk%2F2017%2F06%2F11%2Fquery-folding-and-writing-your-own-sql-queries-in-power-querypower-biexcel-get-transform%2F%3C%2FA%3E)%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

I have a parameter table defined that allows the user to define the filtering values.  I would like to take the data they've inputted and pass that into my query call.  I currently have it set to filter after the source but due to the amount of data, it's quite slow.  I'm hoping to limit the data returned for efficiency.

 

Ideally I'd like to use my current getParameterValue call to define the extra statements that would be appended on to the query (source). Is this possible? If yes, how?

 

I was thinking it would be something like this:

Source = query

#"Filter A" = query + 'and fieldA = ' + getParameterValue(FilterA)

1 Reply
Highlighted
Solution

In general yes. Implementation depends on what you query. You may add parameter directly into your query string and/or take care about query folding to improve performance (for example https://blog.crossjoin.co.uk/2017/06/11/query-folding-and-writing-your-own-sql-queries-in-power-quer...)