How to filter rows with null values in any of its columns in SSRS - ssrs-2008

I want to filter out the output without rows containing null values or blank columns. I am using SQL Server 2012 there is no option named 'Blank' as in SS2005 where I can filter the rows. I also tried following expression but it gives me error or not showing correct output
=IsNothing(Fields!ABC.Value)!= True
=Fields!ABC.Value = ''
Please suggest the solution.

Pull up the tablix or group properties
Switch to "Filters"
Add a new filter
Set the expression to:
=IsNothing(Fields!YourFieldHere.Value)
Set the type to "Boolean" (see screenshot below) otherwise you'll get a "cannot compare data of types boolean and string" error.
Set the value to false
This works for filtering both rows and groups.

We should use the isNothing method in the Expression, change the Text to Boolean
and then Value will be "True"
for example:
Expression
=IsNothing(Fields!TestA.Value)<>True
(Expression type should be Boolean)
Operator
=
Value
=True

Edit the SQL query, so that it will not return NULL values in the column to group on, but let it return a dummy value; for example: ISNULL(columnA, 'dummy')
In the column group definition add a filter: ColumnA <> 'dummy'.

Related

how to understand the statement in SQL

In some stored procedures I see the following statement in where clause:
...
where
(#val1 is null or val = #val)
What does it mean?
I have used this before in a stored procedure when passing a variable that is used to filter the result set. The null value signifies that the parameter should not be used as a filter.
If #val1 is null, then the expression is true and the results are not filtered.
If #val1 is not null, then the results will be filtered and the val column must match the parameter.

Crystal reports selecting record that contain empty strings or "null"

I have a report that for a field called JobNo there are some records that have "null" as the the cell value and some that have an empty string "". there is another field called AccntNo that im also selecting by in the same selection formula.
This is what i have tried without success in the selection formula for crystal reports.
{accnt.accno} = "7015" and
{accnt.jobno} = "" or {accnt.jobno} isnull
any help is apreciated
Selection formula doesn't work as expected, sometimes.
I suppose that this will work
{accnt.accno} = "7015" and
( isnull({accnt.JobNo}) or {accnt.jobno} = "" )
First of all I put parenthesis on 'or' clause.
But, the strangest thing, is that isnull clause must be evaluated before other comparison clauses.

Nested if else Condition in Crystal report

I have a .rpt file , with a view datasource . I have four parameter which i use in filtering the selection. I have written my selection formula like below.
if ({?actype} <> "All") OR ({?actype} <> "All") OR ({?collectorname} <> "All") OR ({?batchno}<> "All") Then
(
if {?actype} <> "All" Then
{CollectorPerformance.accountType} = {?actype};
if {?collectorname} <> "All" Then
{CollectorPerformance.realname} = {?collectorname};
if {?batchno} <> "All" Then
{CollectorPerformance.batchno} = {?batchno}
and
{CollectorPerformance.clientid} = {?clientid}
and
Date({CollectorPerformance.paymentdate}) >= Date({?from})
and
Date({CollectorPerformance.paymentdate}) <= Date({?to})
)
My issue with the formula, above is that it does not filter by realname and actType. I understand the reason is because the key word "and" is missing . however, it filters the batchno correctly> please how do i make it filter by the remaining two if's ? any help would appreciated.
A selection formula has to be one long valid boolean statement, which is, I think, what you were already suggesting when you say the "and is missing". So in order to fix the first half, you just need to translate those statements into one simplified boolean statement instead of individual statements (those that end in a ';').
({?actype}="All" or {?actype}={CollectorPerformance.accountType})
and
({?collectorname}="All" or {?collectorname}={CollectorPerformance.realname})
and
({?batchno}="All" or {?batchno}={CollectorPerformance.batchno})
...
For each parameter, a user can either select "All" or enter a specific value to filter by. If "All" is selected, that particular portion of the statement (The part that looks like {?Parameter}="All") will evaluate to True and no filtering will be done. Otherwise, only records matching the entered parameter value will return True.

String comparisons in JasperReports expressions

A database field named income_source is queried using:
SELECT * FROM table_name WHERE income_source LIKE "salaried%"
This retrieves income_source values with a "salaried" prefix. In iReport, the PrintWhenExpression value for the field is set as:
$F{income_source}.equals("Salaried")? Boolean.TRUE:Boolean.FALSE
Why does the report output differ from the SQL output?
There are a few problems:
The value "salaried%" in the SQL differs from the value of "Salaried" in the expression.
The value "salaried%" uses the % to match all text after the letter d.
There is a bit of redundancy in the PrintWhenExpression.
Try the following expression:
$F{income_source}.startsWith( "salaried" )
Or:
$F{income_source}.trim().toLowerCase().startsWith( "salaried" )
One of those should work. You will also want to ensure Blank when null is checked. Otherwise, the expression becomes:
$F{income_source} == null ? Boolean.FALSE :
$F{income_source}.trim().toLowerCase().startsWith( "salaried" )

PQgetisnull : Not not return true even value is empty in DB

I am working on bug in my Database library which use LibPQ internally.I see following behavior which looks strange to me :
For postgreSql Datatype DATE it returns true if its empty in DB
For postgreSql Datatype TIME it return true if its empty in DB
But for VARCHAR,SMALLINT..it return false even they were empty in DB.
PS. I have not check for other data types yet
The empty string and zero (0) are NOT the same thing as NULL. Run a form of this query to see how many NULLs vs empty strings exist for your field:
SELECT COALESCE(<field_name>,'NULL'), COUNT(*)
FROM <table_name>
WHERE <field_name> = ''
OR <field_name> IS NULL
GROUP BY 1
Replace the empty string ('') in this query with zero to check against numeric fields.