I am struggling to put #parameter with where clause.
Actually my requirement is to display data for both months Jan and Feb in report when they both are selected from parameter checkbox.
I am using
Union All select Months from table where #MonthSelected = 'Jan' AND #MonthSelected ='Feb'
I want to combine that both in where clause, if both are selected than only it will display data as needed or else not.
But I facing challenge in writing that where clause with #MonthSelected along with AND.
Please help me if anyone is aware.
Thank you
Related
I have 2 Datasets (dsDetails and dsProjectID)
I have a table using the dsDetails dataset, and an expression for CityCount to lookup a field in dsProjectID.
=join(LookUpSet(Fields!cbt_projectid.Value,Fields!cbt_projectid.Value,Fields!CityCount.Value, "dsProjectID"),",")
I need to hide the detail row based on the value of the CityCount. If it is >=2 then hide that record associated. See Below, the report should only show the IMS Number 5192 and NOT 4868.
http://i.stack.imgur.com/0gCDE.jpg
I have tried making this into a calculated field, but it doesn't allow a lookup, I have tried many calculations to set the visibility expression, but all to no avail.. I know there is an answer, but as I am new to SSRS I cannot figure this one out. Any help would be appreciated.
Thanks!
The following code hides a row based on sample data:
Data source:
select 1 union all
select 1 union all
select 1 union all
select 1 union all
select 2
Expression in**(Details)** Row Groups
=iif(Fields!ID.Value>1,FALSE,TRUE)
I hope it helps.
Not sure how to do this so was hoping that someone could help, I have a multivalue parameter we shall call 'Week', this has a drop down of 1 through to 4. My data set example is :-
select total from tableA where Week in (#Week)
what I want to do is divide the total by the number of options I pick from the drop down, e.g. if I picked Week 1 & 2, I would want the TSQL statement to use the count of 2 as the value to divide by e.g.
select total/2 from tableA where Week in (#Week)
is this possible?
Thanks P
Have a look into using the Average function,
SELECT AVG(total) FROM tableA WHERE Week IN(#Week)
I would use a user-defined split function to convert the multivalue parameter into rows in a table. These have been posted several times. Then you can simply do something like this:
select sum(A.total), count(distinct Weeks.items)
from tableA as A
inner join dbo.Split(#week) as Weeks on Weeks.items = A.Weeks
I am working on a SSRS report which needs to show a blank row after every group. The group by field is "category". The values it takes are "first quarter 2010", second quarter 2010", "first quarter 2011", "second quarter 2011". I want the data in the column as follows:
Category
First Quarter 2010
Second Quarter 2010
First Quarter 2011
The report gets populated by a sql query. The problem I am having is inserting the blank row after each group.
I have tried to insert a row below inside the group and play around with its visibility property. But have failed. I have also tried to include
UNION NULL, NULL, NULL in my sql query to insert a blank row. BUt since my dataset is huge I am afraid formating in sql will slow the process down .
Please suggest and also let me know if You need more detais. Thanks in advance.
Using the union in your SQL query is the right direction, but you need to use "union all" instead of "union" to keep the database from filtering the result set for unique. Using union all will just add another row and the performance impact should be inconsequential.
I have a tablix like so
Two parameters - begin date and end date
Customer Emp Hires Emp Terminations
XYZ 12 2
What's the best way to do the grouping, specifically the column grouping? I'm currently grouping by customer in the row group and then in the hire field, I'm doing a sum(iif(hire_date between begin and end date,1,0)). Same for termination field but using the employee's termination date. (Essentialy a sum(case when then 1 else 0 end) in SQL
Now, since they may run it for an entire month, an employee might fall in both columns (hired and termed in the same month). Is what I'm doing the best way or is there a more correct/more effient way? If what I'm doing is the best way in SSRS, it seems I should do the pivoting in SQL (if possible) instead for better performance overall?
If you are using SQL Server,I would suggest to perform this grouping in SQL query only by passing date parameters as the SQL processing is quite fast than that of SSRS.
This is my personal experience to improve performance of report.
I am trying to build an access report based on data from multiple different tables within the database.
I have 3 columns which perform calculations, and I am wondering how to put this query together. All 3 columns deal with dates, but calculate them differently.
The first column retrieves the most recent date of action for a userid if the type of action is "B":
select pid, Max(date) as most_recent
from actions
where ref = 'B'
group by pid;
The second column performs a calculation based on 2 fields, one is a date and one is a number in months. I am unsure how to add these two fields so that the number is added to the date as a number of months.
what i have so far is:
select nummonths,Max(lastvisit) from users
the third column I need to select the first date thats in the future for each user (next appointment date), there will be dates before and after this date so its a little difficult:
select uid,date from visits
The code for the last 2 queries needs to be slightly modified, and I was wondering what the best approach would be to join these all together? A type of join?
If you need to build a report with data from the 3 queries, you will need related data to join them. In that case, please send the structure of the tables.
If you need to show 3 lists in one report, you can use subreports: create a new empty report. In design mode, you can add 3 subreports from the toolbox bar. To each of the subreport assign the record source property to the corresponding sql.
regards
I am unsure how to add these two fields so that the number is added to the date as a number of months.
Use the DateAdd() function:
SELECT DateAdd("m", 2, LastVisit) FROM ...
Results in a date two months from the LastVisit date.