Showing posts with label functionality. Show all posts
Showing posts with label functionality. Show all posts

Thursday, February 16, 2012

Average Functionality issue

Hi All,

In my Report using SSRS 2005, I am displaying data using table and this table has table footer in which I am calculating "average" using Avg() function.The values in table rows can be either floating numbers (for eg; -1,-99,5.005) or "N/A". I use the following function to calculate Average
=Avg(Iif(Fields!Channel1.Value="N/A",CDbl("0"),CDbl(Fields!Channel1.Value)),"MainDS")

where "Fields!Channel1.Value" are values in table rows.

Everything works fine if all the table rows are floating point numbers and not "N/A", but as soon as table rows values are "N/A" I encounter "#Error" in the table footer.

Can anyone figure out how to get this code working. Thanks in advance.

Regards,
abhi_viking

the best way is add another field in the dataset. Populate this field with the same value after converting to float and replace those "N/A" with 0. Now, you should be able to use the "Avg" function on this new field which is of float data type.

|||Hi,

Thanks for replying. I am currently doing the same thing using "Iif" in Avg()

=Avg(Iif(Fields!Channel1.Value="N/A",CDbl("0"),CDbl(Fields!Channel1.Value)),"MainDS")

If the value is "N/A", then value is 0, else the value is converted to Double ie; CDbl(Fields!Channel1.Value)

Any Idea how to get this code working.

Regards,
abhi_viking
|||

Pls try,

=avg(iif(IsNumeric(Fields!Channel1.Value),cdbl(Fields!Channel.Value),cdbl(0)))

Priyank

|||I tried using IsNumeric(), but didnt work for me, I got the same error that I used to get Sad
Is there any other way to get this code working ?

Regards,
abhi_viking

|||

First create an new expression to just convert the "N/A" to 0. Then create another epression and do the average of the first expression. I think this should work, if not could you give te details of the error?

|||

The problem is that the IIF statement evaluates both the true and false results (http://msdn2.microsoft.com/en-us/library/27ydhh0d(VS.80).aspx) and DBbl("N/A") fails to evaluate. Perhaps you could try:

Code Snippet

=Avg(

CDbl(

IIF(

Fields!=Channel1.Value="N/A",

0,

Fields!=Channel1.Value

)

)

)

If you still have problems, create a small custom function and pass the value into it and let it return the double. Within the code fragment, you can use a real IF and avoid the problems imposed by IIF.

Larry

|||

Thank you guys for replying back, I will try your suggestions soon and will keep you updated on this topic.

Regards,

abhi_viking

|||Thanks Larry, your code snippet works for me Smile

Average Functionality issue

Hi All,

In my Report using SSRS 2005, I am displaying data using table and this table has table footer in which I am calculating "average" using Avg() function.The values in table rows can be either floating numbers (for eg; -1,-99,5.005) or "N/A". I use the following function to calculate Average
=Avg(Iif(Fields!Channel1.Value="N/A",CDbl("0"),CDbl(Fields!Channel1.Value)),"MainDS")

where "Fields!Channel1.Value" are values in table rows.

Everything works fine if all the table rows are floating point numbers and not "N/A", but as soon as table rows values are "N/A" I encounter "#Error" in the table footer.

Can anyone figure out how to get this code working. Thanks in advance.

Regards,
abhi_viking

the best way is add another field in the dataset. Populate this field with the same value after converting to float and replace those "N/A" with 0. Now, you should be able to use the "Avg" function on this new field which is of float data type.

|||Hi,

Thanks for replying. I am currently doing the same thing using "Iif" in Avg()

=Avg(Iif(Fields!Channel1.Value="N/A",CDbl("0"),CDbl(Fields!Channel1.Value)),"MainDS")

If the value is "N/A", then value is 0, else the value is converted to Double ie; CDbl(Fields!Channel1.Value)

Any Idea how to get this code working.

Regards,
abhi_viking
|||

Pls try,

=avg(iif(IsNumeric(Fields!Channel1.Value),cdbl(Fields!Channel.Value),cdbl(0)))

Priyank

|||I tried using IsNumeric(), but didnt work for me, I got the same error that I used to get Sad
Is there any other way to get this code working ?

Regards,
abhi_viking

|||

First create an new expression to just convert the "N/A" to 0. Then create another epression and do the average of the first expression. I think this should work, if not could you give te details of the error?

|||

The problem is that the IIF statement evaluates both the true and false results (http://msdn2.microsoft.com/en-us/library/27ydhh0d(VS.80).aspx) and DBbl("N/A") fails to evaluate. Perhaps you could try:

Code Snippet

=Avg(

CDbl(

IIF(

Fields!=Channel1.Value="N/A",

0,

Fields!=Channel1.Value

)

)

)

If you still have problems, create a small custom function and pass the value into it and let it return the double. Within the code fragment, you can use a real IF and avoid the problems imposed by IIF.

Larry

|||

Thank you guys for replying back, I will try your suggestions soon and will keep you updated on this topic.

Regards,

abhi_viking

|||Thanks Larry, your code snippet works for me Smile

Average Functionality issue

Hi All,

In my Report using SSRS 2005, I am displaying data using table and this table has table footer in which I am calculating "average" using Avg() function.The values in table rows can be either floating numbers (for eg; -1,-99,5.005) or "N/A". I use the following function to calculate Average
=Avg(Iif(Fields!Channel1.Value="N/A",CDbl("0"),CDbl(Fields!Channel1.Value)),"MainDS")

where "Fields!Channel1.Value" are values in table rows.

Everything works fine if all the table rows are floating point numbers and not "N/A", but as soon as table rows values are "N/A" I encounter "#Error" in the table footer.

Can anyone figure out how to get this code working. Thanks in advance.

Regards,
abhi_viking

the best way is add another field in the dataset. Populate this field with the same value after converting to float and replace those "N/A" with 0. Now, you should be able to use the "Avg" function on this new field which is of float data type.

|||Hi,

Thanks for replying. I am currently doing the same thing using "Iif" in Avg()

=Avg(Iif(Fields!Channel1.Value="N/A",CDbl("0"),CDbl(Fields!Channel1.Value)),"MainDS")

If the value is "N/A", then value is 0, else the value is converted to Double ie; CDbl(Fields!Channel1.Value)

Any Idea how to get this code working.

Regards,
abhi_viking
|||

Pls try,

=avg(iif(IsNumeric(Fields!Channel1.Value),cdbl(Fields!Channel.Value),cdbl(0)))

Priyank

|||I tried using IsNumeric(), but didnt work for me, I got the same error that I used to get Sad
Is there any other way to get this code working ?

Regards,
abhi_viking

|||

First create an new expression to just convert the "N/A" to 0. Then create another epression and do the average of the first expression. I think this should work, if not could you give te details of the error?

|||

The problem is that the IIF statement evaluates both the true and false results (http://msdn2.microsoft.com/en-us/library/27ydhh0d(VS.80).aspx) and DBbl("N/A") fails to evaluate. Perhaps you could try:

Code Snippet

=Avg(

CDbl(

IIF(

Fields!=Channel1.Value="N/A",

0,

Fields!=Channel1.Value

)

)

)

If you still have problems, create a small custom function and pass the value into it and let it return the double. Within the code fragment, you can use a real IF and avoid the problems imposed by IIF.

Larry

|||

Thank you guys for replying back, I will try your suggestions soon and will keep you updated on this topic.

Regards,

abhi_viking

|||Thanks Larry, your code snippet works for me Smile

Average Functionality issue

Hi All,

In my Report using SSRS 2005, I am displaying data using table and this table has table footer in which I am calculating "average" using Avg() function.The values in table rows can be either floating numbers (for eg; -1,-99,5.005) or "N/A". I use the following function to calculate Average
=Avg(Iif(Fields!Channel1.Value="N/A",CDbl("0"),CDbl(Fields!Channel1.Value)),"MainDS")

where "Fields!Channel1.Value" are values in table rows.

Everything works fine if all the table rows are floating point numbers and not "N/A", but as soon as table rows values are "N/A" I encounter "#Error" in the table footer.

Can anyone figure out how to get this code working. Thanks in advance.

Regards,
abhi_viking

the best way is add another field in the dataset. Populate this field with the same value after converting to float and replace those "N/A" with 0. Now, you should be able to use the "Avg" function on this new field which is of float data type.

|||Hi,

Thanks for replying. I am currently doing the same thing using "Iif" in Avg()

=Avg(Iif(Fields!Channel1.Value="N/A",CDbl("0"),CDbl(Fields!Channel1.Value)),"MainDS")

If the value is "N/A", then value is 0, else the value is converted to Double ie; CDbl(Fields!Channel1.Value)

Any Idea how to get this code working.

Regards,
abhi_viking
|||

Pls try,

=avg(iif(IsNumeric(Fields!Channel1.Value),cdbl(Fields!Channel.Value),cdbl(0)))

Priyank

|||I tried using IsNumeric(), but didnt work for me, I got the same error that I used to get Sad
Is there any other way to get this code working ?

Regards,
abhi_viking

|||

First create an new expression to just convert the "N/A" to 0. Then create another epression and do the average of the first expression. I think this should work, if not could you give te details of the error?

|||

The problem is that the IIF statement evaluates both the true and false results (http://msdn2.microsoft.com/en-us/library/27ydhh0d(VS.80).aspx) and DBbl("N/A") fails to evaluate. Perhaps you could try:

Code Snippet

=Avg(

CDbl(

IIF(

Fields!=Channel1.Value="N/A",

0,

Fields!=Channel1.Value

)

)

)

If you still have problems, create a small custom function and pass the value into it and let it return the double. Within the code fragment, you can use a real IF and avoid the problems imposed by IIF.

Larry

|||

Thank you guys for replying back, I will try your suggestions soon and will keep you updated on this topic.

Regards,

abhi_viking

|||Thanks Larry, your code snippet works for me Smile

Sunday, February 12, 2012

Auto-refresh the output of the 'Open Table" action

I checked the options in SQL 2005 Management Studio and it does not appear to be an
available functionality.
Is it possible to have the output of the "Open table" action to refresh the output at a
specified interval?
Thanks.
Probably not as it was never designed for that. There are few reasons to
use that functionality in the first place. The query editior is far more
flexible and does not run the risk of editing data by mistake just from
viewing the data.
Andrew J. Kelly SQL MVP
"Gaetan" <me@.somewhere.com> wrote in message
news:ge2h125kt8381rls43qv4ie3181j1c981r@.4ax.com...
>I checked the options in SQL 2005 Management Studio and it does not appear
>to be an
> available functionality.
> Is it possible to have the output of the "Open table" action to refresh
> the output at a
> specified interval?
> Thanks.
|||I understand the limitations of "Open table". The Query Editor is far more flexible but
unless I missed something, it too does not allow the SQL statements to be auto-rerun at
configurable interval.
On Wed, 15 Mar 2006 19:52:00 -0500, "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote:

>Probably not as it was never designed for that. There are few reasons to
>use that functionality in the first place. The query editior is far more
>flexible and does not run the risk of editing data by mistake just from
>viewing the data.
|||Not as a built in feature but a simple while loop will do it for you. This
will rerun the query every to seconds for 10 loops. Or what ever you need
it to do.
DECLARE @.X INT
SET @.X = 0
WHILE @.x < 10
BEGIN
SELECT *****
WAITFOR DELAY '00:00:10'
END
Andrew J. Kelly SQL MVP
"Gaetan" <me@.somewhere.com> wrote in message
news:6kej12dd7b63n4cq7tr61j26iejd9g7pv9@.4ax.com... [vbcol=seagreen]
>I understand the limitations of "Open table". The Query Editor is far more
>flexible but
> unless I missed something, it too does not allow the SQL statements to be
> auto-rerun at
> configurable interval.
>
> On Wed, 15 Mar 2006 19:52:00 -0500, "Andrew J. Kelly"
> <sqlmvpnooospam@.shadhawk.com> wrote: