Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another iif problem

Status
Not open for further replies.

blindlemonray

Technical User
Nov 24, 2003
130
GB
I didn't realise how many people had issues with the iif statement until I searched!!

Anyway does anybody know why this does not work in a iif statement...

IIf(IsNull([elec]),"",Sum([debit])/Sum([elec]))

[neutral]

 
Can you explain in words what you are trying to do and where you are trying to do it.
 
no probs,

two fields in the table... 'elec' and 'debit' I need to get a percentage of the 'debit' against the 'elec' but if the 'elec' field is null then return a zero value not an error.
 
forgot to say...

several entries for each day and need to sum then all to create a total
 
So does this work (you don't say where you are trying to do this):

iif(nz(elec)=0,0,debit/elec)
 
No, I thought about the nz function but still no joy, its ok but it doesn't seem the like the bit where I ask...
==========================
Sum([debit])/Sum([elec]))
==========================
can you not do this in a iif statement?
 
And this ?
Sum(IIf(IsNull(elec),0,debit/elec))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I just get an overflow error. Could run it through a couple of queries but I was just seeing if it was possible to do it in one!
 
And this ?
Sum(IIf(Nz(elec,0)=0,0,debit/elec))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PH,

no joy, this perform a the sum for each day and then sums them into a total giving a false figure. What I need to do is opposite way round. sum the figures for each day they divide the two against each other giving you an overall percentage

Found a way round it though, when data is uploaded ignore '0' and leave field null, this in turn stops any error being made.

thanks for your time on this one PH

BLR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top