Using IIF and AND in SSRS Expression

I have a table like below

I want to hide the rows where ALL 3 columns are 0. All the columns are of INT data type

My expression is like so:

=IIF((Fields!PastVal.Value=0) AND (Fields!DatePay=0) AND (Fields!Line.Value=0),False,True)

But no data is returned except the column label(heading). What could be wrong with my express?

Thank you.

March 26th, 2015 11:20am

Try this:
=IIF(Fields!PastVal.Value+Fields!DatePay+Fields!Line.Value=0,False,True)

Free Windows Admin Tool Kit Click here and download it now
March 26th, 2015 11:40am

Hi ,

You have misplaced the True,False

Below expression  should work

=IIF((Fields!PastVal.Value=0) AND (Fields!DatePay=0) AND (Fields!Line.Value=0),True,False)

Many Thanks

Chandra

......................................................................................................................................................................

Please mark the post as Answered if the above solution solves your issue.

March 26th, 2015 12:07pm

Thanks for the reply. But I only got back the column label.

It has something to do with SSRS not able to parse the zero(0) as it returns it as string rather than as an integer.

I need help, pls. thanks

Free Windows Admin Tool Kit Click here and download it now
March 26th, 2015 12:33pm

It has something to do with SSRS not able to parse the zero(0) as it returns it as string rather than as an integer.

Um, what? SSRS is quite capable of handling 0's...

Are you trying to tell us that YOUR fields are STRINGs and not INTEGERS?

=IIF(Fields!PastVal.Value+Fields!DatePay+Fields!Line.Value='000',False,True)

March 26th, 2015 12:38pm

0 is interpreted as a string if entered as an WHOLE expression, not when used as you are...

The expression 0 returns a string.

The expression =1+0 returns an in

March 26th, 2015 1:01pm

Thanks. That will mean

=IIF(Fields!PastVal.Value+Fields!DatePay+Fields!Line.Value=0,False,True)

and
=IIF(Fields!PastVal.Value+Fields!DatePay+Fields!Line.Value=0,False,True)

are correct. But I am still not getting values returned even though all fields are integers.
Appreciated.

Free Windows Admin Tool Kit Click here and download it now
March 26th, 2015 1:12pm

Is it possible that one or more of your values are NULL?

Try:

=IIF(Fields!PastVal.Value+Fields!DatePay.Value+Fields!Line.Value = 0, TRUE,
 IIF(Fields!PastVal.Value is Nothing AND Fields!DatePay.Value is Nothing AND Fields!Line.Value is Nothing, TRUE, FALSE) 
 )

March 26th, 2015 1:21pm

In  that case compare 

as below

=IIF((Fields!PastVal.Value="0") AND (Fields!DatePay="0") AND (Fields!Line.Value="0"),True,False)

Or irrespective of data type make every column  as string as below

=IIF(Cstr((Fields!PastVal.Value="0") )AND (Cstr(Fields!DatePay.value)="0") AND (Cstr(Fields!Line.Value)="0"),True,False)

Make sure you select the details row  and set the hide property

Many Thanks

Chandra

......................................................................................................................................................................

Please mark the post as Answered if the above solution solves your issue.

Free Windows Admin Tool Kit Click here and download it now
March 26th, 2015 3:12pm

Hi Zionlite,

Because you have mentioned that the data type of the three fields are both interger, So, the expression shouldn't have any problem. The issue may caused by the structure of report you have designed or you have use some expression in the report.

Please try to provide more details information about the report you have desgined:

  1. Is there any group in the report and did you use tablix or matrix to design the report, please try to provide the snaphot of the report structure like belowIf you have add some group or using some other expression, please provide them),I assumed you have structure like below:

  2. In the step1's snapshot you can find an expression, please try to enter below expression in the last column to test if you will got the correct value of true and false like below:
    =IIF((Fields!PastVal.Value=0) AND (Fields!DatePay.Value=0) AND (Fields!Line.Value=0),True,false)
  3. Generally, if you can got the correct true and false value in step2, the hide and show will work fine unless you have some more complex structure when design the report.

If you still have any problem, please feel free to ask.

Regards,
Vicky Liu

March 27th, 2015 2:50am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics