SSRS parameters - specifying multiple values in one label - reporting-services

Good evening all,
for a parameter in a ssrs report I want to specify the values available. Every label will have the same value, apart from one label - this one will have two values. Everything works fine if I just specify one value per label. But if I use two for one label, it will show error "ORA-01722: invalid number".
I assume I am missing some formatting here to make sure I can pass on two values? The sql query is correct I believe, it specifies the bind by doing "...WHERE account_no in (:account)..."
Below an example of what I am trying to do. Numbers are random
Would appreciate any help here. Thanks

As you used IN SSRS will inject the values into your dataset query. If the parameter is text (ignore the fact it's actually numeric), the query will try to process something like SELECT * FROM myTable WHERE account_no IN ('3333,4444') which is obviously wrong.
You'll need to parse the values in your dataset query with something like this
SELECT * FROM myTable
WHERE account_no in (SELECT [value] FROM string_split(#account, ','))
You haven't mentioned what database you are using, the above is based on SQL Server but the same principle applies.

Related

Working with SSRS dynamic fields

SSRS matrix table is a great way to generate dynamic fields as long as values exist.
However, is there a way to "always" show these dynamic fields even if a value doesn't exist for them? The report field locations varies based on data availability and users have to add missing columns in Excel manually.
Dynamic fields go from 3 to up to 30 (at least for now based on run by values). Adding these values manually would make the report hard to maintain.
The way I have handled for this is in the SQL. I build a table of all the values I will always want, I cross join that table to my final output table and update/insert values where they need to exist. That way I guarantee the rows, and eventually columns in the matrix, exists even if they end up being null.
Does that make sense?
Jesse's solution is a good one, but if for whatever reason you can't or prefer not to change the SQL you can do it in SSRS by forcing a blank value in the cell with a expression like this:
=iif(IsNothing(Fields!.xxx.Value)," ",Fields!.xxx.Value)

Report containing sums from different queries in Access

I am currently working with different tables and queries in Access and I can't find a way to do something very simple. I have the following :
Two queries, qry1 and qry2
One table, tbl1
Both queries and the table have a "NET" field of type float (or double)
What I'd like to do is create a very simple report which would give me the total of the NET column for each of those three objects. I have tried to insert a text box in a blank report and selecting sum(NET) on qry1 in Control Source but it doesn't work, it simply prints '#Error' with no more information.
If I use 'Add Existing field' and drag&drop 'NET' from tbl1 and then edit it to add sum it works but it is repeated for each row which is obviously not what I want. It feels like I'm missing something here or that I might not be using the right tool.
Thanks in advance for your help!
Have you considered the DSum() function? Create three text boxes and set the control source for each text box as follows:
=DSum("NET", "qry1")
=DSum("NET", "qry2")
=DSum("NET", "tbl1")
Note: Aggregate functions (e.g., DSum, DLookup, etc.) have poor performance compared to performing the calculations within a query. It's not clear from your question whether that's an option for you or not.

Access - Enter Parameter Value Error

I have a table that contains all the weeks of the year (using the client's numbering, so Week 1 is in June), and the dates they start. There is a form where they can choose which week they want to look at, so I've used a ComboBox that grabs all the week numbers for which they've entered data in the WeeklyHours table, using
SELECT Format(WeeklyHours.Week,"0") AS Expr1 FROM WeeklyHours GROUP BY WeeklyHours.Week;
This combobox is then supposed to be used as the week filter for a couple queries I've built, using the combobox value as the matching criteria. The problem is that when the form is closed, those queries can't run, and give me the Enter Parameter Value error for the combobox value.
To fix this, I tried to create a new table called SelectedWeek with a single entry called Week_Number. There is then some AfterUpdate code that saves the selected combobox value to the Week_Number field of SelectedWeek.
I then changed the queries to point to [SelectedWeek]![Week_Number], so that the queries will always use whatever the most recently selected week was.
However, I keep getting the Enter Parameter Value error for SelectedWeek!Week_Number, and I can't figure out why.
Any help would be most appreciated.
Thanks,
Joel
Reason the user is prompted for Parameter Value (by the way, it is not an error) is in both cases the Access SQL engine cannot see either referenced values. In first case, the form is closed and in second case column is not properly aligned to a lookup.
In first scenario, simply keep form open which user selects value from combobox when running other queries. Otherwise, all content on form is not callable since it is closed from memory:
SELECT * FROM TableName WHERE weeknumber = Forms!FormName!WeekNumber
In second scenario, use a DLookUp() part of the Domain Function Family.
SELECT * FROM TableName WHERE weeknumber = DLookUp("Week_Number", "SelectedWeek")
And really, domain functions can be generalized as subqueries in SQL:
SELECT * FROM TableName
WHERE weeknumber IN (SELECT Week_Number FROM SelectedWeek)
Even more, you can run a cross join query (tables separated with commas in FROM clause) of the two tables and avoid lookups. Below assumes SelectedWeek is a one-row, one-column table but with the WHERE condition, length is handled and you can explicitly declare columns in either table:
SELECT *
FROM TableName, SelectedWeek
WHERE TableName.weeknumber = SelectedWeek.Week_Number

Is it possible to use IFNULL() with a * in a SELECT statement with MySQL? If not, what is my alternative?

Here is what I have that currently works in a SELECT statement:
SELECT
movieitemdetails.barcode,
IFNULL(movieitemdetails_custom.title, movieitemdetails.title) AS title
FROM
...
The problem is that I need to have my SQL be more dynamic when it comes to column names and the amount of columns I have. I need to use * to dynamically pull back all rows. Here is some example pseudocode to show you what I need:
IFNULL(movieitemdetails_custom.*, movieitemdetails.*) AS *
I need it to bring back all of the columns with the same name on each table and do the IFNULL comparison. Obviously the code above is not correct.
Does anyone have any ideas on how to make what I have more dynamic involving *?
Note to certain people: Please don't give me flak about how I shouldn't use *. I know in general use it's not recommended, but in this specific project it is what we're going with.
No, the IFNULL() function accepts only two scalar expressions, not wildcard expressions like *.
To make this query more dynamic, your options are:
Build the query with application code, appending an IFNULL() expression for each such pair of columns. Then submit the query.
Or:
Fetch all the columns independently with SELECT * ... and then sort out which ones to use in application code.
You would have to do each column individually, like so:
SELECT
movieitemdetails.barcode,
IFNULL(movieitemdetails_custom.title, movieitemdetails.title) AS title
IFNULL(movieitemdetails_custom.col2, movieitemdetails.col2) AS col2
IFNULL(movieitemdetails_custom.col3, movieitemdetails.col3) AS col3
FROM
...
Not sure exactly what you mean by having it be more dynamic regarding the amount of columns though.. a SELECT statement cannot have a variable number of columns, so if you want that behavior you would need to use a stored procedure or build your SQL dynamically.

SSRS set last row as default value for multi-value parameter

I guess that's easy... I have a multi-value parameter that got the list of values from a query. I would like to select as default value the last row.
Can I achieve this using a expression? I would like to avoid creating a second query just to get the last value from the previous query...
In the default parameter expression you can't refer to the field of the dataset, so you can't write something like Last(Field!MyVar.Value, "DataSet1"), as a workaround you can order your dataset to retrive last row as first and use "Get values from a query" which choses first row, if you can't do this then replicate your dataset in the only one solution.
I am working with SSRS 2012 and I was using a multi select option on my report so when I chose the "Get Values from a query" I got all of the values as the default.
I did find a solution. In my report I needed the default name of the town to be the first one so I created another set with the name of the column and a calculated measure that said "[DimTahanot].[Tahana Name].&[אילת]" and filtered it by the same one. (Please ignore the different language). Although hard coded it was good for this report. You could create another hidden parameter for this set if you need it to be the first one by amount or any other parameters that should effect this value, using the filter as a parameter.
Hope this helps.