Showing posts with label iif. Show all posts
Showing posts with label iif. Show all posts

Friday, March 23, 2012

is it possible to do this

is it possible to give this expression in the visiiblity property

=IIF((CountRows("Growth")) = 1,"Data not Available",False)

If the CountRows("Growth") is greater than 1 the graph shows up as needed. But suppose if CountRows = 1 i want data not available to show up in the report

How can i do it

i tried converting it to Cbool("Data not available") but i get an error message

Any help will be appreciated.

Regards

Karen


It seems you are trying to set some property that expects a boolean value (eitherTrue orFalse)

"Data Not Available" is a string and cannot be converted to a boolean value.

If you can post details of what you are trying to do, someone should be able to help you.

|||

Prashant thanks for your answer.

I have a line graph which is been populated by a stored procedure.. and the client wants no graph to appear if there just one value.. This is my sproc..

ALTER Procedure [dbo].[rpt_Growthof10K]@.Cusipvarchar(9)AS--==============================================================================-- Return the appropriate data.--==============================================================================SELECT Cusip, ChartHeader, GrowthDates, GrowthNAVFROMGrowthof10KWHERECusip = @.Cusip
 
IF there is just one record returned by the sproc the graph will plot.. but i would just end up getting the x axis and the y axis and they not enough data to be plotted so instead of showing that i want to show text message saying that "Data not avialable.
I also tried giving this expression =IIf(CountRows("Growth") = 1, True, false) so its displays nothing if it evaluates to True and if the expression is false it shows the Graph...
So i just wanted it to look a bit user friendly by displaying the message instead of the user calling up and saying i cannot see the graph..
 
any help will be appreciated
Regards
Karen

|||

Never mind. I solved it.

For the graph i set the visible property to true if countrows("growth") = 1

and then before the graph i put a text box and i gave this expression in it ...

=IIf(CountRows("Growth") = 1,"Data Not Avialable","")

Regards

Karen

is it possible to do this

is it possible to do give this expression is the visiiblity property

=IIF((CountRows("Growth")) = 1, "Data not Available",False)

If the CountRows("Growth") is greater than 1 the graph shows up as needed. But suppose if CountRows = 1 i want data not available to show up in the report

How can i do it

i tried converting it to Cbool("Data not available") but i get an error message

Any help will be appreciated.

Regards

Karen

There is no way you can convert the string "Data not Available" to a boolean. Instead, put that string into a textbox and place it behind the graph, so it shows if the graph is not visible. Or just set the visibility of the textbox to the opposite of the visibility of the graph. Or are you attempting to get the string to show up on an empty graph?

|||

Thanks Sluggy,

thats what i did tooo..

Regards,

Karen

Wednesday, March 21, 2012

Is it possible to create an IIF function for SQL Server?

Hello!

I tried the following code:

create function dbo.iif
(
@.Expression bit,
@.TruePart sql_variant,
@.FalsePart sql_variant
)
returns sql_variant
as
begin
declare @.ReturnValue sql_variant

if @.Expression=1
begin
set @.ReturnValue=@.TruePart
end
else
begin
set @.ReturnValue=@.FalsePart
end

return @.ReturnValue
end

It works fine with statements like this:
select dbo.iif(1,'True','False')

However, when trying a "real" expression, an error appears:
select dbo.iif((1=0),'True','False')
Line 1: Incorrect syntax near '='.

How can I work around this?

Thank you very much in advance.define a variant, and set the value to be the expression. Use the variant in your iif function instead.|||would CASE serve the purpose?