IIF behavior?
Hi All, How does IIF works? Does it evaluate TRUE and FALSE closes and do condition selection or checks the condition first and then selects correct close (TRUE or FALSE)?
May 20th, 2011 9:25am

it evaluate true condition and you can setup results for both true and false conditions
Free Windows Admin Tool Kit Click here and download it now
May 20th, 2011 9:30am

A bit more information about the problem : I have column and it's values can be FLOAT or TEXT. All values can be either all are FLOAT eather all are TEXT, no mixed rows. In a footer I need result of a column: If rows are TEXT I put TEXT in footer, if FLOAT - I need to do some agregate calculations with floats. So I do simple IIF check : IIF (First(MyColumn) LIKE TEXT, TEXT, CALCULATION). If my values are numeric CALCULATION script (just script, not in IIF clause) works fine and on TEXT values it shows #error (no brainer, that's normal). If I put CONDITION in my IIF script - works normal on FLOAT values and gives #error on TEXT too. So it looks like IIF firts check if TFUE and FALSE parts are valid. If not - all IIF produces #error. This makes no sence, since if i need just TRUE part, FALSE part can contain whatet ever it wants, even bananas... BR Marius
May 20th, 2011 9:38am

Hi, The format for the IIF expression as below =IIF(<Condition>, True, False) Hope its helpful.... Thanks KumarKG, MCTS
Free Windows Admin Tool Kit Click here and download it now
May 20th, 2011 9:40am

I know the format. I put my example in simpliefied way, just to get an idea. It's not about format, it about workflow...
May 20th, 2011 9:45am

Hi Bala, From your previous replies it looks like you have Conversation issues. I'm not able to understand your question 100% but still try to use in-built conversation function. Pleasae let us know your feedback. Thanks KumarKG, MCTS
Free Windows Admin Tool Kit Click here and download it now
May 20th, 2011 9:55am

I think the problem comes from storing mixed type information in one column. It is rarely a good idea. I suggest to split the field into Float and Text parts when you create the Data Source for your report. This way you will not need any conditional logic in the report itself, you will do this in the backend. Of course, the best solution will be to not store such information in the table in one field to begin with.For every expert, there is an equal and opposite expert. - Becker's Law My blog
May 20th, 2011 10:31am

Hi All, How does IIF works? Does it evaluate TRUE and FALSE closes and do condition selection or checks the condition first and then selects correct close (TRUE or FALSE)? IT evaluates compiles the syntaxes of both true and false conditions , depending upon the condition it returns either true condition or the other one . ThanksRajkumar Yelugu
Free Windows Admin Tool Kit Click here and download it now
May 20th, 2011 11:02am

It's not possible to seperate data. Here is full story : I have one report and populate with different sets of technological data - temperatures, pressures, runtimes and so on. In some cases some parameters exists, in some - they don't. I.e., there can be pressure in one dataset (it will be FLOAT/NULL values), but no pressure parameter in other (it will have "NoConfig" string - TEXT value). So same column can be FLOAT or TEXT. Also, in some cases, there can be no values in a rows (ie, no pressure record for some rows) - thus FLOAT/NULL values. One column contains RunTime - how many time specific defice was running. In some cases this parameter can not exist too. What I want to do. I want to calculate weighted average of parameters with respect to RunTime. I table footer field I need either TEXT "NoConfig" (if there is no parameter), either weighted average (if both parameter and RunTime exists). Since, I have NULLS mixed with FLOATS, I need to check if value is not null too. This part of textbox Expression calculates weightet average and do NULL check (sum(RunTime*Pressure)/sum(RunTime) sum(iif( not IsNothing(Fields!RunTime.Value) AND NOT IsNothing(Fields!Pressure.Value), cdbl(Fields!RunTime.Value) * cdbl(Fields!Pressure.Value),0.0))/ sum(iif( not IsNothing(Fields!RunTime.Value) AND NOT IsNothing(Fields!Pressure.Value), cdbl(Fields!RunTime.Value),0.0)) Now, If I do check if parameter exists (IIF First(Fields!Pressure.Value) LIKE "NoConfig", "NoConfig", TheScriptAbove) I got #error output. If I replace script with just some number (IIF First(Fields!Pressure.Value) LIKE "NoConfig", "NoConfig", 99.0) It works - I have 99.0 if parameter exists and "NoConfig", if not. So I think, IIF first checks boith TRUE and FALSE statements and when show #error but not evaluate logical condition. If parameter does not exits Average script will produce #error, but IIF should not run this script, because it's in FALSE statement and my logical condition is TRUE. wuf. lot of text... marius
May 20th, 2011 2:34pm

Hi Bala, IIF function do executes both parts true and false, I suggest you to use switch function instead of IIF like below, =Switch(First(Fields!Pressure.Value) LIKE "NoConfig", "NoConfig", NOT(First(Fields!Pressure.Value) LIKE "NoConfig"), call function to calculates weightet average ) More details about the switch function, you can see the following article, Expression Examples (Report Builder 3.0 and SSRS): http://msdn.microsoft.com/en-us/library/ms157328.aspx If you have any question, please feel free to ask. Thanks, Eileen
Free Windows Admin Tool Kit Click here and download it now
May 26th, 2011 10:06am

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

Other recent topics Other recent topics