Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 SSRS 2008 r2 iff with lookup

Author  Topic 

jassie
Constraint Violating Yak Guru

332 Posts

Posted - 2013-10-03 : 14:31:45

In a ssrs 2008 r2 report, I have found the following expression and I would like you to explain the following code to me:

=IIF(Lookup(Fields!SK.Value, Fields!SK.Value, Fields!StCount.Value, "DS_StCount") = Nothing, 0, Lookup(Fields!SK.Value, Fields!SK.Value, Fields!StCount.Value, "DS_StCount"))


I know that a lookup function compares the first values to see if they are equal, and if so they value in the third column is returned. However I do not know what this enire
iif statement is doing. Can you explain it to me?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-04 : 01:57:25
it checks if the value SK has a valid match in dataset DS_StCount if yes it will return the StCount of the first matching row. otherwise it will return 0. IIF is like CASE WHEN. It checks for a condition and returns two return value one for true part and another for false.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

jassie
Constraint Violating Yak Guru

332 Posts

Posted - 2013-10-04 : 09:45:58
Thanks!
Go to Top of Page
   

- Advertisement -