SOLVED
Home

How do you do a parameter query when not using Microsoft Query?

%3CLINGO-SUB%20id%3D%22lingo-sub-94026%22%20slang%3D%22en-US%22%3EHow%20do%20you%20do%20a%20parameter%20query%20when%20not%20using%20Microsoft%20Query%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-94026%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20workbook%20that%20uses%20the%20ODBC%20interface%20part%20of%20Microsoft%20Query%20to%20query%20a%20DB2%20database.%26nbsp%3B%20The%20workbook%20actually%20queries%20over%2020%20different%20tables.%26nbsp%3B%20I%20have%20one%20cell%20in%20the%20workbook%20that%20is%20the%20main%20search%20parameter%20for%20all%20the%20queries%20(for%20example%20WHERE%20CUST_NUM%20%3D%20%3F).%26nbsp%3B%20I%20have%20the%20queries%20to%20always%20use%20this%20value%20and%20automatically%20execute%20when%20the%20value%20changes.%26nbsp%3B%20This%20way%20I%20change%20one%20cell%20and%20the%2020%20queries%20all%20execute.%3C%2FP%3E%3CP%3EI'm%20trying%20to%20move%20this%20process%20from%20using%20ODBC%20under%20Micrsoft%20Query%20to%20use%20the%20JDBC%20interface%20under%20the%20%22Get%20Data%20%2F%20From%20Database%20%2F%20From%20IBM%20DB2%20Database%22%20path.%26nbsp%3B%20I%20can't%20find%20how%20to%20do%20this%20same%20process%20and%20would%20appreciate%20any%20guidance.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-94026%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EGet%20%26amp%3B%20Transform%20Data%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EParameter%20Query%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-95670%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20do%20a%20parameter%20query%20when%20not%20using%20Microsoft%20Query%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-95670%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3BI%20looked%20at%20the%20other%20ways%20to%20do%20this%20in%20the%20other%20posts%20and%20while%20it%20was%20tempting%20to%20work%20on%20putting%20both%20of%20these%20in%20one%20query%20I%20went%20with%20this%20simple%20approach%20of%20setting%20the%20privacy%20settings%20to%20%22always%20ignore%22.%26nbsp%3B%20The%20main%20reason%20for%20this%20is%20in%20reality%20I%20don't%20have%20just%20one%20query%20that%20I%20need%20to%20read%20this%20parm%20and%20execute%2C%20but%20I%20have%20about%2020%20different%20queries%20against%20other%20tables%20that%20need%20to%20use%20this%20same%20query%20value.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20everyone%20for%20your%20great%20input%20on%20this.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-95507%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20do%20a%20parameter%20query%20when%20not%20using%20Microsoft%20Query%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-95507%22%20slang%3D%22en-US%22%3EThanks%20for%20sharing%20the%20links%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-95502%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20do%20a%20parameter%20query%20when%20not%20using%20Microsoft%20Query%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-95502%22%20slang%3D%22en-US%22%3E%3CP%3EMy%20%240.02%20regarding%20Formula.Firewall%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1)%20I%20agree%20that's%20quit%20common%20to%20switch%20private%20settings%20off%20to%20avoid%20the%20issue.%20Here%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fblog.crossjoin.co.uk%2F2017%2F07%2F04%2Fdata-privacy-settings-in-power-bipower-query-part-4-disabling-data-privacy-checks%2F%3Futm_source%3Dfeedburner%26amp%3Butm_medium%3Dfeed%26amp%3Butm_campaign%3DFeed%253A%2Bwordpress%252FCpjz%2B%2528Chris%2BWebb%2527s%2BBI%2BBlog%2529%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fblog.crossjoin.co.uk%2F2017%2F07%2F04%2Fdata-privacy-settings-in-power-bipower-query-part-4-disabling-data-privacy-checks%2F%3Futm_source%3Dfeedburner%26amp%3Butm_medium%3Dfeed%26amp%3Butm_campaign%3DFeed%253A%2Bwordpress%252FCpjz%2B%2528Chris%2BWebb%2527s%2BBI%2BBlog%2529%3C%2FA%3E%20is%20step%20by%20step%20how%20to%20do%20that%20and%20why%20it's%20not%20always%20good%20practice.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E2)%20I%20personally%20prefer%20to%20keep%20privacy%20settings%20by%20default%20and%20combine%20the%20query%20by%20the%20way%20to%20avoid%26nbsp%3B%3CSPAN%3EFormula.Firewall.%20Security%20is%20the%20point%2C%20but%20not%20the%20main%20one%20here%20-%20when%20you%20distribute%20your%20workbook%20to%20other%20people%20you%20have%20to%20ask%20everyone%20to%20change%20default%20settings%20and%20explain%20how%20to%20do%20that.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EIn%20his%20another%20post%20Chris%20gives%20explanation%20how%20to%20avoid%26nbsp%3Bthe%20issue%20practically%20for%20exactly%20the%20same%20case%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fblog.crossjoin.co.uk%2F2017%2F06%2F26%2Fdata-privacy-settings-in-power-bipower-query-part-3-the-formula-firewall-error%2F%3Futm_source%3Dfeedburner%26amp%3Butm_medium%3Dfeed%26amp%3Butm_campaign%3DFeed%253A%2Bwordpress%252FCpjz%2B%2528Chris%2BWebb%2527s%2BBI%2BBlog%2529%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fblog.crossjoin.co.uk%2F2017%2F06%2F26%2Fdata-privacy-settings-in-power-bipower-query-part-3-the-formula-firewall-error%2F%3Futm_source%3Dfeedburner%26amp%3Butm_medium%3Dfeed%26amp%3Butm_campaign%3DFeed%253A%2Bwordpress%252FCpjz%2B%2528Chris%2BWebb%2527s%2BBI%2BBlog%2529%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20didn't%20try%20Value.NativeQuery%2C%20but%20combining%20Excel%20parameter%20and%20SQL%20queries%20in%20one%20works%20fine%2C%20used%20that%20approach%20before%20seen%20above%20post.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-95448%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20do%20a%20parameter%20query%20when%20not%20using%20Microsoft%20Query%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-95448%22%20slang%3D%22en-US%22%3EHi%20John%2C%3CBR%20%2F%3E%3CBR%20%2F%3EKeep%20going%20it's%20worth%20it!%3CBR%20%2F%3E%3CBR%20%2F%3ETo%20address%20your%20first%20point%2C%20Close%20and%20Load%20to...%20Connection%20Only.%20Those%20are%20actually%202%20separate%20steps.%20In%20your%20screen%20shot%20your%20Load%20To..%20is%20greyed%20out%20as%20you%20must%20have%20already%20loaded%20that%20query%20once%20and%20now%20you%20were%20editing%20it.%20In%20that%20case%20you%20did%20the%20right%20thing%20and%20used%20the%20Right%20Click%20option%20to%20access%20Load%20To...%20Connection%20Only%3CBR%20%2F%3E%3CBR%20%2F%3EOn%20the%20second%20issue%20you%20should%20(I%20think)%20resolve%20this%20by%20going%20to%20New%20Query%20-%20%26gt%3B%20Query%20Options%20-%20%26gt%3B%20Privacy%20%26gt%3B%20Always%20Ignore%20Privacy%20Level%20settings.%20There's%20a%20hyperlink%20there%20as%20well%20if%20you%20want%20to%20find%20out%20more%20about%20what%20turning%20off%20Privacy%20warnings%20does%2C%20however%20it%20is%20fairly%20standard%20practice%20to%20set%20it%20to%20Always%20Ignore%20(but%20find%20out%20about%20it%20and%20make%20your%20own%20call%20%3A)%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-95443%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20do%20a%20parameter%20query%20when%20not%20using%20Microsoft%20Query%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-95443%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20a%20bunch%20and%20I'm%20getting%20a%20lot%20closer.%26nbsp%3B%20However....%20as%20I'm%20following%20your%20steps%20in%20step%205%20you%20indicate%20to%20%22Home%20-%20Close%20%26amp%3B%20Load%20-%20Connection%20only%22%20-%20I%20don't%20see%20an%20option%20to%20close%20as%20%22connection%20only%22.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F18538iAD099207D6378ED7%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22QEditor.jpg%22%20title%3D%22QEditor.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI'm%20on%20the%20current%20channel%20so%20my%20Office365%20has%20been%20updated%20with%20latest%20Get%20%26amp%3B%20Transform%20stuff.%3C%2FP%3E%3CP%3ENow%20I%20did%20finally%20get%20there%20by%20rmb%20on%20the%20saved%20query%20and%20select%20%22Load%20to%22%20which%20gave%20me%20this%20window%20where%20I%20could%20select%20%22connection%20only%22%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F18539iC6262FFF605D3946%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22QEditor2.jpg%22%20title%3D%22QEditor2.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI%20then%20went%20and%20edited%20my%20SQL%20query%20to%20now%20be%3C%2FP%3E%3CP%3E.......%20AND%20KUNNR%20%3D%20'%22%20%26amp%3B%20QueryKUNNR%26nbsp%3B%20%26amp%3B%20%22')%20ORDER%20BY%20KTOKD%20.......%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20it%20tries%20running%20I%20now%20get%20this%3A%3C%2FP%3E%3CP%3EFormula.Firewall%3A%20Query%20'KNA1%20by%20KUNNR'%20(step%20'Source')%20references%20other%20queries%20or%20steps%2C%20so%20it%20may%20not%20directly%20access%20a%20data%20source.%20Please%20rebuild%20this%20data%20combination.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20I%20said%20-%20oh%20so%20close%20now.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-95433%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20do%20a%20parameter%20query%20when%20not%20using%20Microsoft%20Query%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-95433%22%20slang%3D%22en-US%22%3EThanks%20Sergei%3CBR%20%2F%3E%3CBR%20%2F%3EHere's%20the%20article%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fwww.linkedin.com%2Fpulse%2Fhow-used-named-cells-parameter-inputs-power-query-wyn-hopkins%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.linkedin.com%2Fpulse%2Fhow-used-named-cells-parameter-inputs-power-query-wyn-hopkins%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-95325%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20do%20a%20parameter%20query%20when%20not%20using%20Microsoft%20Query%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-95325%22%20slang%3D%22en-US%22%3E%3CP%3EJohn%2C%20pINDIRECT%20or%20how%20you'll%20call%20it%20is%20the%20query%20which%20you%20shall%20generate%20yourself.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20brief%2C%20within%20Excel%20give%20to%20your%20D1%20cell%20name%2C%20for%20example%2C%20myParam.%20Stay%20on%20it%2C%20click%20in%20Ribbon%20Data-%26gt%3BFrom%20Table%2FRange.%20In%20query%20editor%20convert%20column%20to%20Text%20and%20take%20the%20value%20from%20the%20cell%2C%20M%20script%20code%20will%20look%20like%3C%2FP%3E%3CPRE%3Elet%0A%20%20%20%20Source%20%3D%20Excel.CurrentWorkbook()%7B%5BName%3D%22myParam%22%5D%7D%5BContent%5D%2C%0A%20%20%20%20AsText%20%3D%20Table.TransformColumnTypes(Source%2C%7B%7B%22Column1%22%2C%20type%20text%7D%7D)%7B0%7D%5BColumn1%5D%0Ain%0A%20%20%20%20AsText%3C%2FPRE%3E%3CP%3EAfter%20that%20you%20may%20add%20result%20to%20your%20query%20as%20...%20%5B%22SELECT%20*%20%22%20%26amp%3B%20myParam%20%26amp%3B%20%22...%5D%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9832%22%20target%3D%22_blank%22%3E%40Wyn%20Hopkins%3C%2FA%3E%26nbsp%3Bpublished%20recently%20detailed%20post%20how%20to%20pick-up%20parameters%20from%20Excel%20cells%20into%20G%26amp%3BT%2C%20only%20i%20don't%20remember%20where.%20If%20Wyn%20is%20around%20hope%20he%20will%20give%20the%20link%20and%2For%20comments.%20On%20the%20other%20hand%20you%20may%20find%20in%20other%20places.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20check%20before%20what%20you%20connection%20works%20without%20any%20parameters%2C%20just%20add%20your%26nbsp%3B%3CSPAN%3E%22123456%22%20directly%20into%20the%20Query%3D%20string.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-95300%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20do%20a%20parameter%20query%20when%20not%20using%20Microsoft%20Query%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-95300%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20the%20tip%2C%20but%20I'm%20struggling%20getting%20something%20to%20work.%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20my%20spreadsheet%20I've%20put%20in%20cell%20C1%20the%20value%20%22D1%22%20and%20then%20in%20cell%20D1%20I%20put%20the%20value%20%22123456%22%20for%20example.%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20in%20the%20query%20I%20modified%20it%20to%3A%3C%2FP%3E%3CP%3ESource%3DDB2.Database(%22server%22%2C%20%22database%22%2C%20Query%3D%5B%22SELECT%20*%20%22%20%26amp%3B%20%22WHERE%20COL1%20%3D%20'ABC'%20and%20COL2%20%3D%20'%22%20%26amp%3B%20pINDIRECT(c1)%20%26amp%3B%20%22'%22%20%22%5D)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20get%20this%3A%3CBR%20%2F%3EExpression.Error%3A%20The%20name%20'pINDIRECT'%20wasn't%20recognized.%26nbsp%3B%20Make%20sure%20it's%20spelled%20correctly.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-94038%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20do%20a%20parameter%20query%20when%20not%20using%20Microsoft%20Query%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-94038%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20John%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20didn't%20work%20with%20DB2%2C%20just%20my%20guess%20if%20that%20could%20work%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3ESource%3DDB2.Database(%22server%22%2C%20%22database%22%2C%20Query%3D%5B%22SELECT%20something%22%20%26amp%3B%20pFromMyCell%5D)%3C%2FPRE%3E%3CP%3Ewhere%20pFromMyCell%20is%20query%2Ffunction%20which%20returns%20the%20string%20from%20your%20cell%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
John Murray
Occasional Contributor

I have a workbook that uses the ODBC interface part of Microsoft Query to query a DB2 database.  The workbook actually queries over 20 different tables.  I have one cell in the workbook that is the main search parameter for all the queries (for example WHERE CUST_NUM = ?).  I have the queries to always use this value and automatically execute when the value changes.  This way I change one cell and the 20 queries all execute.

I'm trying to move this process from using ODBC under Micrsoft Query to use the JDBC interface under the "Get Data / From Database / From IBM DB2 Database" path.  I can't find how to do this same process and would appreciate any guidance.

9 Replies

Hi John,

 

I didn't work with DB2, just my guess if that could work

 

Source=DB2.Database("server", "database", Query=["SELECT something" & pFromMyCell])

where pFromMyCell is query/function which returns the string from your cell

Thanks for the tip, but I'm struggling getting something to work. 

In my spreadsheet I've put in cell C1 the value "D1" and then in cell D1 I put the value "123456" for example. 

Now in the query I modified it to:

Source=DB2.Database("server", "database", Query=["SELECT * " & "WHERE COL1 = 'ABC' and COL2 = '" & pINDIRECT(c1) & "'" "])

 

I get this:
Expression.Error: The name 'pINDIRECT' wasn't recognized.  Make sure it's spelled correctly.

John, pINDIRECT or how you'll call it is the query which you shall generate yourself.

 

In brief, within Excel give to your D1 cell name, for example, myParam. Stay on it, click in Ribbon Data->From Table/Range. In query editor convert column to Text and take the value from the cell, M script code will look like

let
    Source = Excel.CurrentWorkbook(){[Name="myParam"]}[Content],
    AsText = Table.TransformColumnTypes(Source,{{"Column1", type text}}){0}[Column1]
in
    AsText

After that you may add result to your query as ... ["SELECT * " & myParam & "...]"

 

@Wyn Hopkins published recently detailed post how to pick-up parameters from Excel cells into G&T, only i don't remember where. If Wyn is around hope he will give the link and/or comments. On the other hand you may find in other places.

 

Please check before what you connection works without any parameters, just add your "123456" directly into the Query= string.

 

Thanks a bunch and I'm getting a lot closer.  However.... as I'm following your steps in step 5 you indicate to "Home - Close & Load - Connection only" - I don't see an option to close as "connection only".

QEditor.jpg

I'm on the current channel so my Office365 has been updated with latest Get & Transform stuff.

Now I did finally get there by rmb on the saved query and select "Load to" which gave me this window where I could select "connection only":

QEditor2.jpg

I then went and edited my SQL query to now be

....... AND KUNNR = '" & QueryKUNNR  & "') ORDER BY KTOKD .......

 

When it tries running I now get this:

Formula.Firewall: Query 'KNA1 by KUNNR' (step 'Source') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.

 

As I said - oh so close now. 

Solution
Hi John,

Keep going it's worth it!

To address your first point, Close and Load to... Connection Only. Those are actually 2 separate steps. In your screen shot your Load To.. is greyed out as you must have already loaded that query once and now you were editing it. In that case you did the right thing and used the Right Click option to access Load To... Connection Only

On the second issue you should (I think) resolve this by going to New Query - > Query Options - > Privacy > Always Ignore Privacy Level settings. There's a hyperlink there as well if you want to find out more about what turning off Privacy warnings does, however it is fairly standard practice to set it to Always Ignore (but find out about it and make your own call :)



My $0.02 regarding Formula.Firewall

 

1) I agree that's quit common to switch private settings off to avoid the issue. Here https://blog.crossjoin.co.uk/2017/07/04/data-privacy-settings-in-power-bipower-query-part-4-disablin... is step by step how to do that and why it's not always good practice.

 

2) I personally prefer to keep privacy settings by default and combine the query by the way to avoid Formula.Firewall. Security is the point, but not the main one here - when you distribute your workbook to other people you have to ask everyone to change default settings and explain how to do that.

 

In his another post Chris gives explanation how to avoid the issue practically for exactly the same case https://blog.crossjoin.co.uk/2017/06/26/data-privacy-settings-in-power-bipower-query-part-3-the-form...

 

I didn't try Value.NativeQuery, but combining Excel parameter and SQL queries in one works fine, used that approach before seen above post.

Thanks for sharing the links

 I looked at the other ways to do this in the other posts and while it was tempting to work on putting both of these in one query I went with this simple approach of setting the privacy settings to "always ignore".  The main reason for this is in reality I don't have just one query that I need to read this parm and execute, but I have about 20 different queries against other tables that need to use this same query value.

 

Thanks everyone for your great input on this.