Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 IIF Statement

Author  Topic 

werhardt
Constraint Violating Yak Guru

270 Posts

Posted - 2008-11-03 : 09:56:26
Not sure if you can help me out. I am trying to creat this IIF statment in my Microsoft Visual Studio field. I did it once before and it worked. The one that worked is in red, the one that I am having problems with is in black. I am not sure what I am doing wrong. Let me know if you can help me.

Thanks

Wendy


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-03 : 09:57:56
can you atleast post the expression that errored? I didnt understand what you mean by red and black.
Go to Top of Page

werhardt
Constraint Violating Yak Guru

270 Posts

Posted - 2008-11-03 : 10:07:16
Sorry I thought I did.


Here is one that did work.

=IIF(Fields!clmNumberQtr3_2008.Value=0, "N/A", sum(Fields!clmNumberQtr3_2008.Value-Fields!clmNumberQtr2_2008.Value)/ Fields!clmNumberQtr2_2008.Value * 100 & "%")

Here is the one I am trying to get working.

=IIF(Fields!clmnumber.Value=0,"N/A", Sum(Fields!clmnumber.Value/Fields!totalcharges.value)


quote:
Originally posted by visakh16

can you atleast post the expression that errored? I didnt understand what you mean by red and black.

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-03 : 10:10:01
wat about this?

=IIF(Fields!clmnumber.Value=0,"N/A", Sum(IIF(Fields!totalcharges.value=0,0,Fields!clmnumber.Value/Fields!totalcharges.value))
Go to Top of Page

werhardt
Constraint Violating Yak Guru

270 Posts

Posted - 2008-11-03 : 10:37:35
This is working, but the ones that have a something in the column it is saying 8.94621773. I need it to say, .89%. When I try to multiply it by 100, I get errors in all columns.


=IIF(Fields!clmNumber.Value=0,"N/A", IIF(Fields!TotalCharges.Value=0,0,Fields!clmNumber.Value/Fields!TotalCharges.Value))

quote:
Originally posted by visakh16

wat about this?

=IIF(Fields!clmnumber.Value=0,"N/A", Sum(IIF(Fields!totalcharges.value=0,0,Fields!clmnumber.Value/Fields!totalcharges.value))


Go to Top of Page

werhardt
Constraint Violating Yak Guru

270 Posts

Posted - 2008-11-03 : 10:39:44
Nevermind it works! I change what is bolded...]=IIF(Fields!clmNumber.Value=0,"N/A", IIF(Fields!TotalCharges.Value=0,0,Fields!clmNumber.Value/Fields!TotalCharges.Value)*100)

quote:
Originally posted by werhardt

This is working, but the ones that have a something in the column it is saying 8.94621773. I need it to say, .89%. When I try to multiply it by 100, I get errors in all columns.


=IIF(Fields!clmNumber.Value=0,"N/A", IIF(Fields!TotalCharges.Value=0,0,Fields!clmNumber.Value/Fields!TotalCharges.Value))

quote:
Originally posted by visakh16

wat about this?

=IIF(Fields!clmnumber.Value=0,"N/A", Sum(IIF(Fields!totalcharges.value=0,0,Fields!clmnumber.Value/Fields!totalcharges.value))




Go to Top of Page
   

- Advertisement -