how to manipulate SSRS multiple values parameters in a dataset - reporting-services

i have a simple ssrs report in which i have one multiple values parameter.
I want to use the returned values to execute some queries on another table, but when i create the second dataset and i try to get the list of returned values i get ssrs error.
Example:
Multiple values parameter: #MyParam1
Anthony
Michael
Mary
I want to select for example only the values that starts with 'M' and populate with the filtered data another multiple values parameter called #MyParam2.
When i try to parse #MyParam1 in my dataset query i get the error because teh returned value is an array type. I read on some blogs that i can use the JOIN function , but how i can use directly in the Dataset TSQL code?
thanks a lot!

You could use the original table for the parameters and filter it by your selection for your main query.
SELECT FIRST_NAME, USER_LAST_NAME, USER_ID
INTO #TEMP_USERS
FROM USERS
WHERE FIRST_NAME IN (#MyParam1)
Then JOIN on the TEMP table to filter for the parameter selections and add your criteria.
JOIN #TEMP_USER U ON U.USER_ID = X.USER_ID AND U.FIRSTNAME LIKE ('M%')

Related

Lookup using textbox value as source showing too many rows + SSRS

I did a lookup function in ssrs where the source is a reportItem reference. I want to return the value from the table that I am looking up based on the reportItem reference. The report is retrieving the correct values, but and I'm getting repeated rows and I'd like to know if there's a way to eliminate that. My parameters in the tablix is based on a ticket number.
The underlying data has 3 transactions but 9 rows are currently being returned.
In SSRS, my query is:
Select
ticketno, name, control, value
from ticket a
inner join details b on a.ticketno = b.ticketno
where control like 'LS%' and ticket = 'ED08'
The return result contains 4 rows transactions
ie:
Ticket
Name
Control
Value
ED08
Eng
LS1
A
ED08
Acct
LS2
B
ED08
Med
LS3
C
In SSRS, I used a table and hard coded the Name as it's possible that there will be no values.
I hard coded Eng, Acct, Med, Dent for names.
I entered an expression on each individual row with an expression
=lookup(ReportItems!textbox.Value,Fields!Name.Value,Fields!Value.Value, "UDF_Det")
However, when I run the report, I get extra rows.
The transactions retrieved from the ticket in SQL only retrieved 3 rows, so I would have expected that. Is there a way to filter on row specific data?
I have looked at this post Adding values to a Report when there is no Data in query SSRS but since I am not doing any calculations I'm not sure why I am getting repeat rows.
My design looks like this:
Output looks like this:
Acually, now I've edited your question I understand the problem. :)
You can just get a list of Name and left join from it to your existing query.
You maybe able to get the list from an existing table (hopefully) or you could hardcode one (avoid if possible).
Assuming all the Names you need are in your ticket table you could use something like this...
SELECT DISTINCT [Name] FROM ticket
(if name comes from another table, just change the query to suit)
then left join your existing query to this, something like
SELECT n.[Name], t.ticketno, t.control, t.value
FROM (SELECT DISTINCT [Name] FROM ticket) n
LEFT JOIN (
Select ticketno, name, control, value
from ticket a
inner join details b on a.ticketno = b.ticketno
where control like 'LS%' and ticket = 'ED08'
) t
ON n.[Name] = t.[Name]
which should give you something like
Name
Ticket
Control
Value
Eng
ED08
LS1
A
Acct
ED08
LS2
B
Med
ED08
LS3
C
Dent
NULL
NULL
NULL
Then you can simply have one row in the detail group in your table to output the results.
If this does not help, post some sample data from your database tables and show the full report design including row groups etc

Filter query - editing results

In MS access, I have a query that i filter with a list of keywords through a second query. The second select query (which acts as a filter) takes the original (data) query and a keyword table and selects from the data query only the entries that match one of the keywords in the list.
I want to edit a field in the resulting query but access doesnt let me. From what i gather from google & Co. My issue might be caused by not having a relationships between the data query and the keyword table. What can i do to enable editing of the data ? If i were to create a relationship between the keyword table and the data query, how would i design it since 1 keyword does not correspond to one entry in the data query.
Edit: here is the SQL code
Select Sales.saleID, Sales.saleText1, Sales.saleText2, Sales.clientFirstName, Sales.clientLastName, Sales.clientOk
From Sales, Keywords
Where (((Sales.saleText1) Like Keywords!Keyword)) or (((Sales.saleText2) Like Keywords!Keyword));
This returns the correct data but then i cannot edit the clientOk field in the datasheet view (clientOk is a number field)
Thanks in advance for the help
Try something like this:
Select
Sales.saleID, Sales.saleText1, Sales.saleText2, Sales.clientFirstName, Sales.clientLastName, Sales.clientOk
From
Sales
Where
(Sales.saleText1 In (Select [Keyword] From Keywords))
or
(Sales.saleText2 In (Select [Keyword] From Keywords));

mysql query using column values as parameter in query phpMyAdmin

I have a query i have been working on trying to get a specific set of data, join the comments in duplicate phone numbers of said data, then join separate tables based on a common field "entry_id" which also happens to be the number on the end of the word custom_ to pull up that table.
table named list and tables containing the values i want to join is custom_entry_id (with entry_id being a field in list in which i need the values of each record to replace the words in order to pull up that specific table) i need entry_id from the beginning part of my query to stick onto the end of the word custom for every value my search returns to get the fields from that custom table designated for that record. so it will have to do some sort of loop i guess? sorry like i said I am at a loss at this point
this is where i am so far:
SELECT * ,
group_concat(comments SEPARATOR '\r\n\r\n') AS comments_combined
FROM list WHERE `status` IN ("SALEA","SALE")
GROUP BY phone_number
//entry_id is included in the * as well as status
// group concat combines the comments if numbers are same
i have also experimented on test data with doing a full outer join which doesnt really exist. i feel if you can solve the other part for me i can do the joining of the data with a query similar to this.
SELECT * FROM test
LEFT JOIN custom_sally ON test.num = custom_sally.num
UNION
SELECT * FROM test
RIGHT JOIN custom_sally ON test.num = custom_sally.num
i would like all of this to appear with every field from my list table in addition to all the fields in the custom_'entry_id' tables for each specific record. I am ok with values being null for records that have different custom fields. so if record 1 has custom fields after the join of hats and trousers and record 2 has socks and shoes i realize that socks and shoes for record 1 will be null and hats and trousers for record 2 will be null.
i am doing all this in phpmyadmin under the SQL tab.
if that is a mistake please advise as well. i am using it because ive only been working with SQl for a few months. from what i read its the rookie tool.
i might be going about this all wrong if so please advise
an example
i query list with my query i get 20,000 rows with columns like status, phone_number, comments, entry_id, name, address, so on.
now i want to join this query with custom fields in another table.
the problem is the custom tables' names are all linked to the entry_id.
so if entry_id is 777 then the custom table fields are custom_777
my database has over 100 custom tables with specials fields for each record depending on its entry_id.
when i query the records I don't know how to join the custom fields that are entry_id specific to the rest of my data.i will pull up some tables and data for a better example
this is the list table:
this is the custom_"entry_id"
Full Outer Join in MySQL
for info on full outer joins.

How to remove multiple values from SSRS parameter drop down

I have a report where I want to add a parameter as a drop down. The database has more than 13,000 records and the parameter I want to add is of the building names in the record. There are around 6 different building names. When I add the parameter by taking Values from a query and passing the building name as the value, the drop down repeats the 6 building names of all 13,000 records rather than just the 6 building names.
Is there a way where I can filter it to show the 6 building names and then show the records related to that building name?
SELECT new_studentid, new_studentinformationid, new_firstname, new_lastname, new_building, new_busnumber, new_grade, new_primaryhomeroom,documentbody FROM StudentInformation WHERE(new_building = #new_building) AND (new_primaryhomeroom = #new_primaryhomeroom)
You will need to make a query just for the parameter drop-down. It should probably be something like this:
SELECT DISTINCT new_building
FROM StudentInformation
Then for the HomeRoom parameter, use this query:
SELECT DISTINCT new_primaryhomeroom
FROM StudentInformation
WHERE(new_building= #new_building)

SQL Server Report Filter Expressions

So I have two datasets called Employee and EmployeeData. Employee is the main dataset that is used by the report and I want to add a filter to it. The filter parameter is created as EmployeeID. Employee has columns Name, Department, Job, etc. EmployeeData has columns Name, EmployeeID, Address.
I'm trying to filter using EmployeeID on Employee so I need to do some sort of join with EmployeeData using Name as the key. This would be easy in SQL but since I'm new to SSRS, I don't know what the syntax of the expression would look like here.
Thanks
Create another parameter #employeename and set it's default value to the employee name from the employeename dataset, then use that parameter to filter the Employee dataset based on the like operator and the name field.
SSRS is very sensitive to parameter order, so you may need to delete and recreate them in the correct order.