Hide Detail Row based on Expression Textbox - reporting-services

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.

Related

how to group and filter on aggregate in SSRS

I have a requirement to report the number of people who have more than one record in the dataset for my SSRS report and I can't quite get how to filter on the grouping.
So if the dataset results are:
ID PersonID FileID
1 1234 abc
2 7890 ade
3 5647 aer
4 1234 xyz
I would like to report 1. There is one person who has more than 1 record.
Is there an expression or something I can use to do this?
Thank you.
You can use LookupSet and CountDistinct function to get the required count, however you will need the textbox used to show the calculation be in a scope.
If you want to show the number of persons with more than one record as a total in your table use this expression:
=CountDistinct(
IIF(
LookupSet(
Fields!PersonID.Value,Fields!PersonID.Value,
Fields!ID.Value,"DataSetName"
).Length>1,Fields!PersonID.Value,Nothing)
)
Set it outside any group scope:
However if you want to show the number of persons with more than one record outside your tablix in a textbox, you can add an additional tablix and delete the necessary rows and columns to leave only one textbox then set the dataset property to the dataset name you are using and use the same expression.
It should produce:
Note my dataset has more rows to ilustrate the functionality. In the right side there is only one textbox with the count.
Let me know if this helps.
If you want the result to be something like shown below.
Steps:
Create a group on Person ID
Right Click on Group > Add Total > Before
Add a column and put =Count(Fields!PersonID.Value)
If you want to display only Persons having more than one, set the visibility property of the tablix row.

Add "ALL" to drop down which is fetching values from query - SSRS 2008 r2

I have report, which has drop down to select warehouse code and it show stock position at that selected warehouse, these warehouse codes are populated through query at available values part, i would like to add in the same list as ALL, how to achieve this?
Current view at drop down
WH 1
WH 2
WH 3
Desired view at drop down
ALL
WH 1
WH 2
WH 3
please provide your inputs
You should create a specific dataset just for this parameter. Then from that dataset Just Add a union query
SELECT 'ALL' as FieldName
UNION ALL
*Your Dataset Query
Then set your parameter to Get value from a query then select the dataset you've just created.
Parameter Dataset:
SELECT NULL AS Value, '<ALL>' as Label
union all
SELECT DISTINCT WAREHOUSE AS Value, WAREHOUSE as Label
this will create a dataset with a distinct list of warehouses in both the value and label column - there is a reason for this which I will explain further on.
Now in your dataset change the where clause to:
WHERE WAREHOUSE=CASE WHEN #wh IS NULL THEN WAREHOUSE ELSE #wh END
By creating a NULL value with its own label you are creating an extra row in the dataset and by passing NULL in (using the where clause above) you are effectively selecting the entire table.

SSRS sum values by different group and merge cells

I got a sum Table 1 from a dataset, grouped by a parent Group 1 and a child group 2.For C, it sums values for different Sites.
The table I really want is to merge the SumValue under one column and re-name the group, e.g., C1 & C2 instead of Site-C1 & Site-C2.
I have tried to rename the Group 2 from Site_C1 and Site_C2 to C1 and C2, but it still splits to different columns:
Thank you for your help in advance.
It is similar to a question you posted before. As I said in that moment you can use an expression to conditionally set the grouping settings in your matrix. Add a matrix and add the Group 1 to Column Groups
In the Group properties / Group on put this expression:
=IIF(
Fields!Group.Value="C",
RIGHT(Fields!Subgroup2.Value,2),
Fields!Group.Value
)
Note Subgroup2 is Group 2 in your case.
Put the same expression on the header (the selected cell in the screenshot). It will preview the following matrix:
Let me know if this helps.
I would add one ore more calculated field to the dataset. There you can add the values of the relevant columns like this:
=IIF(IsNothing(Fields!C10.Value), 0,Fields!C10.Value)
+ IIF(IsNothing(Fields!C11.Value), 0,Fields!C11.Value)
+ IIF(IsNothing(Fields!C11.Value), 0,Fields!C12.Value)
In your table, don't bind a column to C10, C11.. but bind it to the calculated field.

Date/time field/column need query to have distinct dates (without times) & sorted correctly

I have a list of records that have a date/time field/column; I want a query to get just the distinct days (removing the time, like 1/1/14, 1/2/14, etc) & sorted correctly. Its going into a form's combo box row source so a user can filter/narrow-down the info on the screen per day
Here is my original query:
SELECT TOP 1 "*** ALL ***" AS ord_tdate FROM qryOrderEntriesNotBilled
UNION SELECT DISTINCT FORMAT(ord_tdate, "mm/dd/yy") FROM qryOrderEntriesNotBilled
ORDER BY 1;
Here is a simplified view for the sake of the question at hand:
SELECT DISTINCT FORMAT(ord_tdate, "mm/dd/yy") FROM qryOrderEntriesNotBilled
ORDER BY 1;
Both of the above work, but the order is wrong, its obviously sorting by number (1st one) rather than overall value as seen here:
Things I have tried unsuccessfully:
DATEVALUE(ord_tdate) solved the simplified view, but with original query (union) it doesn't work correctly as seen below
CDate(Datevalue(ord_tdate)) & CDate(FORMAT(ord_tdate, "mm/dd/yy")) had same results as above
Include a second field expression, DateValue(ord_tdate), in the row source query. Sort by that field. In the combo properties, select 2 as the column count and set the column width for that second column to zero.
This query returns what I think you want in Access 2007 with qryOrderEntriesNotBilled as an actual table instead of a query.
SELECT DISTINCT
FORMAT(ord_tdate, "mm/dd/yy") AS date_as_text,
DateValue(ord_tdate) AS date_as_date
FROM qryOrderEntriesNotBilled
UNION ALL
SELECT TOP 1
"*** ALL ***",
Null
FROM qryOrderEntriesNotBilled
ORDER BY 2;
My personal preference is to use a custom single-row Dual table for the "fabricated" query row. If you would like to try that approach you can find a procedure to create your own here. But a dedicated table is absolutely not a requirement for this. It's purely a matter of developer preference.

Using a count of SSRS 2012 Parameters within the TSQL of my dataset

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