Showing posts with label expression. Show all posts
Showing posts with label expression. 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?

Monday, March 19, 2012

Is it possible to change the operator of an expression at run time?

I have a report I have created in local mode, in a Winform ReportViewer using VB.net.

Is it possible to change the operator of an expression at run time? That is, I have a filter on a list that looks like this:

Expression: =Fields!InvNum.Value

Operator: =

Value: =Parameters!InvNum.Value

It is possible in code to change the operator from = to >= at the time I run the report? If so, what is the syntax? What I would like to do (don't know it is possible) is to have the operator set to >= at the time the the report is run and then set it back to = when a user selects a specific value for a Parameter for the report. Is this possible?

I suppose I can set it in the load event of the form that contains the ReportViewer, but if this is possible I have not been able to discover the syntax.

Anyone?

You can't change the filter operator at run-time. But you can change the filter expression to =IIF(<your condition>, Fields!InvNum.Value=Parameters!InvNum.Value, Fields!InvNum.Value>=Parameters!InvNum.Value), and the filter value to =true.|||

Thank you for responding.

It's not clear to me what you're saying. I mean I understand that you can change the filter expression as a whole (and not the filter operator) and I understand that you can do that with an Immediate IF statement, but where?

Are you saying that you can change the expression in code, at run time? If so, how and Where, specifically?

Or, are you saying that in the Filter tab of the List component that you can enter an IIF there? If so, what kind of value would I put in <your condition>?

It may be that I am asking a question that seems illogical to you, like "How is time?". But to me, what I am trying to do is pretty common. I am trying to figure out a way to bring lots of information into a report and then give the user the ability to whittle it down if he wants to.

|||

OK. I think I understand some of this. I created an additional string parameter for the report called IWantToSeeAllRows. I set the default value to Y. Then in the filter tab of the list, in the expression column I typed the following:

=IIF(Parameters!IWantAllRows.Value = "Y", Fields!InvNum.Value>=Parameters!InvNum.Value, Fields!InvNum.Value=Parameters!InvNum.Value)

After typing the above RS put an = character in the Operator column and <Blank> in the Value column of the grid in the filter tab.

When running the report I get an error of "Cannot compare data of types system boolean and system string. Please check the data type returned by the filter expression.

I am really guessing here as to where just exactly to place the code etc., but the documentation that I've found on the matter is not explicit for this particular issue. What am I missing?

|||

Most likely you changed the filter value expression to a constant value like TRUE (which is interpreted as string - hence the type mismatch).

Change the filter value expression to =True (which evalutes to a boolean)

-- Robert