IIF statements in a report

myblueshadow

New Member
Joined
Aug 4, 2011
Messages
12
I am trying to format a report using an IIF statement. Basically I have a list of 3 possible names under a group. Each group could have 1-3 names included. Each name is housed in a different column within the query. I would like to do an IIF statement to not show Staff1 if it is blank and so on, and move the next non-blank staff to the top so there aren't large empty spaces. I tried this:

=IIF([Staff1] IsNull, [Staff2], IIF([Staff2] IsNull, [Staff3], Null))
but, obviously, it didn't work. Help!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
The correct syntax is:

=IIf(Not IsNull([Staff1]),[Staff1],IIf(Not IsNull([Staff2]),[Staff2], IIf(Not IsNull([Staff3]), Null)

And I would just like to point out that your table structure is not properly normalized (as you shouldn't have repeating fields like that). You should have them stored as RECORDS in another table, and not as columns.
 
Upvote 0
I realize that, however, I didn't create the database so I have no control over how it's designed.

That is giving me an error message.
 
Upvote 0
Being rude is supremely helpful!!! Thank you!

It says #Error

Why is it that when someone posts for help on a forum, the replies are all about how much their database sucks and pointing out how much they don't know? Clearly, I posted for help because I needed help. I didn't post so that I could be condescended to!!!
 
Upvote 0
Being rude is supremely helpful!!! Thank you!
How is that being rude?

It says #Error
That is what it says in the control? Then it might not like the NULL at the end so change it to "" instead.
Why is it that when someone posts for help on a forum, the replies are all about how much their database sucks and pointing out how much they don't know?
It isn't that, but we don't just give out blind answers just because we are here doing this to help people LEARN how to do it the right way and not to provide band-aid solutions which will only break and get worse over time.
Clearly, I posted for help because I needed help. I didn't post so that I could be condescended to!!!
If you felt that you were being treated that way then I'm sorry but the situation is this - you need to understand that on a forum we do not see what you see. So this was being pointed out to you. And if what I wrote stung then you may need to think about getting a thicker skin because it wasn't harsh in the least. It only stated what needed to be stated. If you went to a doctor and said, "doc, I have this ache, what is it?" I think he would be asking you for more information as he can't diagnose without information. Now I tried to put a humorous spin on instead of just saying "NEED MORE INFO" which is what I could have done. But would you have actually learned from that or would you learn more with a statement that we can't see what you see.

So, sorry your feathers got ruffled and, if you wish, I will let someone else respond to your posts from now on. I don't have to answer your posts if you would rather me not.
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,319
Members
452,905
Latest member
deadwings

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top