Forum Discussion
Restrict rows retrieved by query?
- 10 years ago
The single-qoutes is needed as part of my SQL query to filter a string column in the SQL database
The 1st double-qoute stop the "free text query" and allows to insert a parameter
Ampersand is needed to merge the parameter with the SQL code around paramater
The 2nd double-qoute continue the "free text query"
I hope this explains the code.
Now back to your problem... 19 foreign keys "scary face". I assume that you users will need to be able to filter several parameters at once? This will force you to type SQL code from now until you retire. As I see it you will have to create 19*18*17*16*15*14*13*12*11*10*9*8*7*6*5*4*3*2 combinations of your code + create 19 parameters lists with a complete set of values for your user - and this will only give them the option to select a single value per parameter. I don't think this is the right path for you. You will need to many different variations of your code because consider that your user only select a parameter in a few of your lists, then the rest will be blank but if you query your SQL with WHERE a.Country = '' then you will only get the customer with no country value (blank), but what you really want is not to filter the country column in your SQL table, so you will somehow have to handle all the combinations of posible where clauses you need.
With single value per parameter I mean they will not be able to select both US and UK customers but only one of them - unless you make you parameters free text values. Then you will be able to chance the SQL to use IN instead of =, but your users will only get the wanted result if they learn to write the right text - using my example from before this would be 'US', 'UK' and your where clause should be "WHERE a.Country IN (" & CountryParameter & ")"
Anonymous, that's where we're headed. We're looking at using SSAS Tabular modeling for business analytics. But at this stage of the project, we have flattened operational data that we intend to load into SSAS, and I was wondering if we could use that data for operational analysis as well - retrieving detail rows for analysis instead of the lowest level of aggregation.
I have prototyped this in Excel using a Microsoft Query data connection and applying criteria to the query that are linked to cells in the spreadsheet. This gives the user the ability to change the value of the parameters in the spreadsheet and get the corresponding rows. It's also not too hard for someone experienced in Excel to add criteria to the query, without knowing SQL. (There are some gotchas there, which we'll need to train on.)
When I saw Power BI, I liked the power of reports, visualizations and dashboards very much. And I wondered if it could do the same thing, with greater presentation capabilities. But it appears the answer is no, so we may have to remain "old school" with Excel and Microsoft Query, unless someone has a solution or recommendation?
Thanks.
SamTrexler Take a look at Parameters, they were just added to the Desktop in the April release. They may provide a way to filter the information, but I haven't played with them yet enough tell you how they work and/or if they'll work for your use case.
- SamTrexler10 years agoHelper IV
Eno1978, Thanks for your responses.
I have looked at query parameters, but can't find a way to have them affect the SQL statement sent to SQL Server, without resorting to coding on the Advnaced Editor. And this needs to be an end-user capability, so that's out for my immediate purposes.
Any suggestions?