Check if a field exists in parameters select value - reporting-services

I have a dataset which brings in distinct values of a column 'A' of table 'B' and these form the select values for a parameter 'Param_A'. In addition to this I have a main dataset which brings in data from table 'B' and contains the column 'A' as 'Field_A'.I do not want to alter the main dataset and hence I am using a tablix filter to filter out the result set of the main dataset. The tablix filter is supposed to be performing the below functionality :
Expression:
Fields!Field_A.value in (Parameter!Param_A.value) or Fields!Field_A.value is NUll
Boolean Operator :
"="
Value:
True
But I am unable to use the operator 'in'. It gives me an error.Could you please help me out with this?

I used the 'inStr' Operator which eliminated the possibility of using 'in' operator:
iif(InStr(Join(Parameters!Project.Value,","),Fields!project_name.value)>0,
true,false)
This helped me!

Related

Custom column in Oracle/SQL/My-Sql Query?

I have database ready with data as per below screenshot, green column is customized column which I need to generate while querying data from SQL/Oracle.
Logic: If Actual_Completion_Date is not an empty/null, then bring
Actual_Completion_Date into Completion_Date else get
Schedule_Completion_Date in Completion_Date column.
Is there any way, where I should write If statement while defining column names in SQL query without stored procedure help.
If both date field contains NULL value then use simply COALESCE(). IF first one is NULL then second one value will show if it's not NULL. If first one is not null then will sshow first one value.
SELECT Activity_Details, Actual_Completion_Date
, Schedule_Completion_Date
, COALESCE(Actual_Completion_Date, Schedule_Completion_Date) AS Completion_Date
FROM tbl;
You can simply do this in the SELECT clause of your query. For example using the IF() function like this in mysql:
SELECT Activity_Details, Actual_Completion_Date, Schedule_Completion_Date, IF(Actual_Completion_Date IS NOT NULL, Actual_Completion_Date, Schedule_Completion_Date) AS Completion_Date
FROM tbl;
The IF function takes a condition that should return True or False as the first argument. If the condition evaluates to true, the second argument is returned and if it evaluates to false, the third.
In Oracle or Microsoft SQL server you would do something similar in the SELECT clause of your query, but using CASE WHEN ... THEN ... ELSE ... END
Oracle (and MySQL) both support generated columns. That means that you can add the logic as part of the table definition. I'm not sure if this is what you are asking for, but in Oracle, this looks like:
alter table t add column completion_date date generated always as
(coalesce(Actual_Completion_Date, Schedule_Completion_Date)) virtual;
This would be calculated when the table is queried and available to any query that uses the table.

The Value expression for the textrun ‘Textbox15.Paragraphs[0].TextRuns[0]’ contains an error: [BC30201] Expression expected

I received this error when I am trying to run a select statement in a text box in SSRS. So, basically, I am trying to return a field which is not in the given dataset. So I have run a subquery which returns the value using the existing dataset as a container.
But I don't know how to represent that return value in the Expression field. Because the expression field returns a value which is within the dataset provided.
I have provided the SQL that I have written.
Any suggestions would be much appreciated.
My intention is to return the "CommentText" value. However, the dataset does not contain any commenttext field, but an EmpID field. So I have created the subquery below that brings up the CommentText from LaborDtlComment table and when it matches with the EmpID in the report dataset it returns the CommentText Value.
select [CommentReturnQuery].[LaborDtlComment_CommentText] as [LaborDtlComment_CommentText],
[EmpBasic].[EmpID] as [EmpBasic_EmpID]
from Erp.EmpBasic as EmpBasic
inner join (select [LaborDtlComment].[CommentText] as [LaborDtlComment_CommentText],
[LaborDtl].[EmployeeNum] as [LaborDtl_EmployeeNum]
from Erp.LaborDtlComment as LaborDtlComment
inner join Erp.LaborDtl as LaborDtl on LaborDtlComment.Company = LaborDtl.Company
and LaborDtlComment.LaborHedSeq = LaborDtl.LaborHedSeq
and LaborDtlComment.LaborDtlSeq = LaborDtl.LaborDtlSeq) as CommentReturnQuery
on EmpBasic.EmpID = CommentReturnQuery.LaborDtl_EmployeeNum
My aim is to show the CommentText value in a text field. So I will create the
text field and it will contain the SQL that I have written. Can anyone help
me in this case?
It maybe simpler to use the SSRS function lookup (single paired 1 to 1) or lookupset (multiple 1 to many).microsoft lookup reference
You will have to create the query/dataset to return CommentText from LaborDtlComment table with the EmpID

SSIS Derived Column condition to replace null values based on a specific date

I am working on a SSIS Package that will populate a SharePoint 2013 list with data from other SP lists.
I have created a Derived Column in the package, which is intended to replace null based on dates that are greater than or equal to a specific date in the data list. However, I am having trouble with the expression. Below is a condition and expression example that I am have trouble with.
REPLACENULL(ColumnName,"mm/dd/yyyy" > = GETDATE())
Any assistance to point out what I am doing wrong is appreciated.
Use this expression:
((DT_DATE)"9-1-2016") >= (DT_DATE)ColumnName ? NULL((DT_WSTR, 50)) : ColumnName
Notice: REPLACENULL is not useful for you here. What REPLACENULL does is that it:
Returns the value of second expression parameter if the value of first expression parameter is NULL". (See here)
You don't want to replace NULL, you want NULL!
Syntax for REPLACENULL is REPLACENULL(expression 1,expression 2) where
expression 1 :
The result of this expression is checked against NULL.
expression 2 :
The result of this expression is returned if the first expression evaluates to NULL.
If you're trying to REPLACE NULL values of a column based on another column's datetime condition, try something like this :
[column_1] >= GETDATE() ? REPLACENULL([column_2],"desired value") : [column_2]

SSRS - Limiting results using multiple parameters

I'm creating a debtor invoicing report which has two parameters.
Parameter 1: This is a single value parameter called #booking_date. I filter the results(main dataset) by adding this into the query as a query parameter.
Eg. WHERE BookingDate = #booking_Date
Parameter 2: This parameter has two specified values - Yes or No. The parameter is called #live_run and the default value is 'No'. Basically, when this parameter has the default value of 'No', it does not limit/effect the results in any way. On the other hand, when this parameter has a value of 'Yes', it should limit the results by only displaying the bookings where the invoice has been paid off. There is a field I can use for this called Booking_Paid_off as follows - WHERE Booking_Paid_Off = 1.
I have parameter 1 in place, but I am unsure how to bring in Parameter 2 because it will be based on two conditions, do I need to use an If statement or a case statement? Do I need to create a new dataset for the second Parameter? I only want to limit the results with Parameter 2 ONLY if Parameter 2 has a value of Yes, otherwise I want the results to stay the same.
You have many options. You can switch out the Dataset entirely based on the parameter or use an IF inside the dataset to determine which query to run or simply check the parameter in your WHERE clause.
I recommend the latter.
SELECT
Field1,
Field2
FROM
Table1
WHERE
(
(#live_run = 'Yes' and Booking_Paid_Off = 1)
or (#live_run <> 'Yes')
)

Tablix Filter for Including NULL in SSRS

I have an SSRS report. It has a Marks dropdown, and a resultset "Classresult". When I select any value from Marks dropdown, it filters my result for selected value and displays the result.
Say when I select "100" from marks dropdown, it filters my Classresult dataset and shows all results with 100 value.
But it doesnot show values which have NULL in marks field.(the resultset ClassResult contains NULL values.
Is there any way i can include NULL values ??
Currently my condition is:
Marks == Parameters!Marks.Value
Do you have the ability to wrap an IsNull() around the Class result field in your datasource?
Like IsNull(ClassResult,0) AS Classresult
This will replace nulls with a zero. Alternately you could replace the 0 with a different value of your choice.
Use the IsNothing() function to check for a NULL value in an SSRS expression. It returns TRUE if the value is NULL.
You can include NULL in the query that populates the Marks drop down. (If you put the available values in statically, then add it there...) but here is how you can do it in the query.
SELECT ValueField, LabelField
FROM MarksTable
UNION
SELECT '(NULL)', '--NULL--'
Then in the query whose results you are filtering add
ISNULL([Marks], '(NULL)') as Marks