Showing posts with label follows. Show all posts
Showing posts with label follows. Show all posts

Sunday, February 19, 2012

IIF Function

I've been looking at the online help and it appears that
this statement should function as follows:
Select IIf(1 > 0 , 'Yes', 'No')
If 1 is greater than 0, Yes should be returned, if not
then No
Sql returns an error message: Incorrect syntax near '>'
Any Ideas?
ThanksYou must be looking at help for MS Access or Excel or something. There is
no such thing as IIF in SQL Server. Maybe try CASE:
SELECT CASE WHEN 1 > 0 THEN 'Yes' ELSE 'No' END
"Raghib" <anonymous@.discussions.microsoft.com> wrote in message
news:100801c4f1fe$f73d1860$a301280a@.phx.gbl...
> I've been looking at the online help and it appears that
> this statement should function as follows:
> Select IIf(1 > 0 , 'Yes', 'No')
>
> If 1 is greater than 0, Yes should be returned, if not
> then No
> Sql returns an error message: Incorrect syntax near '>'
> Any Ideas?
> Thanks
>|||If you search for IIF in SQL Server Books Online, you will indeed find it.
However, you have to look at the title (or location) and realize it is for
Analysis Services only.
This is not a TSQL function, but rather an MDX function.
--
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Aaron Bertrand [MVP]" <aaron@.TRASHaspfaq.com> wrote in message
news:%23GAGeFg8EHA.2600@.TK2MSFTNGP09.phx.gbl...
> You must be looking at help for MS Access or Excel or something. There is
> no such thing as IIF in SQL Server. Maybe try CASE:
> SELECT CASE WHEN 1 > 0 THEN 'Yes' ELSE 'No' END
>
>
> "Raghib" <anonymous@.discussions.microsoft.com> wrote in message
> news:100801c4f1fe$f73d1860$a301280a@.phx.gbl...
>> I've been looking at the online help and it appears that
>> this statement should function as follows:
>> Select IIf(1 > 0 , 'Yes', 'No')
>>
>> If 1 is greater than 0, Yes should be returned, if not
>> then No
>> Sql returns an error message: Incorrect syntax near '>'
>> Any Ideas?
>> Thanks
>

IIF expression problem

Hello all,

If anyone could give me a hand on this it would be greatly appreciated. The problem i am having is as follows: On a rdlc report I have a column which I am generating a currency value based on a nested IIF statement. What is happening is if I don't have the if statement for the column and just calculate like so : =Fields!Amount.value * 0.02 the number comes out correctly, however if I have it in the following iif statement it automatically rounds the values.

=FormatCurrency(IIF(Fields!Amount.Value = 114.00,((Fields!Amount.Value * .02)* 2),0)Or

IIF(Fields!Amount.Value = 20.00,((Fields!Amount.Value * .02) * 12),0)Or

IIF(Fields!Amount.Value = 216.00,(Fields!Amount.Value * .02),0))

Any insight would be great

Thanks

whats the datatype of Fields!Amount.value ... is it an integer or decimal