Formula for # of Room Nights omitting false data
Hi,
I have this formula in excel that I am trying to recreate in SmartSheet:
=IF(OR(H7815=$D$1,I7815=$D$1),"",DATEDIF(H7815,I7815,"D"))
Criteria is Check-In Date and Check-Out Date. The $D$1 is 12/31/9999 which I want to count as 1 night. When that date appears it is in both columns so it produces an Invalid Operation.
Darla Brown
What you meditate on, you empower!
Best Answers
-
Debbie Sawyer ✭✭✭✭✭✭
When would you need a null value?
Would the logic be:
Take the Checkin date from the Checkout date, if one of the dates is missing then, return a null value?
If so, =[Check-Out Date]@row - [Check-In Date]@row will do just that anyway...
(I still don't understand the significance of comparing to a strange date of 12/31/9999 (as the dates will never match this)... Apologies if my lack of understanding is frustrating! Happy to chat via zoom if it would be easier?
Kind regards
Debbie
-
Debbie Sawyer ✭✭✭✭✭✭
Ahh Thank you - I understand more now! :)
This should work:
=IFERROR([Check-Out Date]@row - [Check-In Date]@row,"")
The invalid operation is showing as the 12/31/9999 is a text value and not a date. So with the IFERROR statement place it will return a null entry rather than an error message.
See if this works for you.
(Thank you for sharing the screen shot - made so much more sense!)
Kind regards
Debbie
Answers
-
Debbie Sawyer ✭✭✭✭✭✭
Is there any chance you could explain your scenario a little more?
I take it you are not just trying to work out the number of nights between Check In-Date and Check-Out Date?
What is the significance of 12/31/9999 in this function?
The way I am reading your function (please forgive me for not understanding it) is:
If the Check-In Date is equal to 12/31/9999 or the Check-Out Date is equal to 12/31/9999 then return a null value otherwise find the Date Difference in Days between the Check-In Date and the Check-Out Date.
Is that what you want it to do?
I'd love to try and help - but at the moment I'm not understanding why you can't just do a simple =[Check-Out Date]@row - [Check-In Date]@row!
Kind regards
Debbie
-
Darla Brown ✭✭✭✭✭✭
Yes, you are reading that correctly. I did try the simple =[Check-Out Date]@row - [Check-In Date]@row function but the 12/31/9999 threw in the Invalid Operation error.
I don't know why this date shows up except it may be when the employee rate is used for that stay. Not really sure. In my excel column, it still counts it as 1 night. I inherited this excel document and I've been slowly migrating to SS. The file is 30 mb with very complicated formulas all throughout. It's been a daunting task!
Darla Brown
What you meditate on, you empower!
-
Debbie Sawyer ✭✭✭✭✭✭
Are you sure that both your Check-In Date column and your Check-Out Date columns are in Date Datatype and not Text Number?
Sometimes when we import data from Excel the data types don't always set correctly in the Smartsheet end...
-
Darla Brown ✭✭✭✭✭✭
Yes. They are both in Date type. How can I return the null value using the simple formula?
Darla Brown
What you meditate on, you empower!
-
Debbie Sawyer ✭✭✭✭✭✭
When would you need a null value?
Would the logic be:
Take the Checkin date from the Checkout date, if one of the dates is missing then, return a null value?
If so, =[Check-Out Date]@row - [Check-In Date]@row will do just that anyway...
(I still don't understand the significance of comparing to a strange date of 12/31/9999 (as the dates will never match this)... Apologies if my lack of understanding is frustrating! Happy to chat via zoom if it would be easier?
Kind regards
Debbie
-
Darla Brown ✭✭✭✭✭✭
It's not frustrating. I understand when you can't see it's difficult. Here is a a snipit of what I'm looking at when I apply the simple rule. This data is imported from Amex website in csv form. So these are their dates. I have no control, but do not want to manipulate data, just report it.
Darla Brown
What you meditate on, you empower!
-
Debbie Sawyer ✭✭✭✭✭✭
Ahh Thank you - I understand more now! :)
This should work:
=IFERROR([Check-Out Date]@row - [Check-In Date]@row,"")
The invalid operation is showing as the 12/31/9999 is a text value and not a date. So with the IFERROR statement place it will return a null entry rather than an error message.
See if this works for you.
(Thank you for sharing the screen shot - made so much more sense!)
Kind regards
Debbie
-
Darla Brown ✭✭✭✭✭✭
YES!! That worked. Thank you so much!!
Darla Brown
What you meditate on, you empower!
-
Debbie Sawyer ✭✭✭✭✭✭
Phew!! We got there! ha ha
Thank you for sticking in there with me!
Have fun with Smartsheet :)
Kind regards
Debbie
-
Darla Brown ✭✭✭✭✭✭
LOL! No Worries! Thanks for helping me figure it out.
Darla Brown
What you meditate on, you empower!
-
Debbie Sawyer ✭✭✭✭✭✭
You're welcome.
If you haven't already done so, could you flag the part of this thread with the final answer in it, so that the community know you have a result to your query. Thanks Darla. Have a good rest of the day :)
-
Darla Brown ✭✭✭✭✭✭
Already done. Thanks!
Darla Brown
What you meditate on, you empower!
Help Article Resources
Categories
I figured it out! Updated formula to get the 2 decimal places as well.<\/p>
=\"We are at \" + IFERROR(ROUND([% closed rate]@row * 100, 2), \"//www.santa-greenland.com/community/discussion/67032/\") + \"% closed rate on ticket status for the month of \" + Month@row<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":322,"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[]},{"discussionID":108861,"type":"question","name":"IF\/AND Formula","excerpt":"Formulas are the bane of my existence and I really need to take a class! Today I'm trying to set up a formula to throw a flag when 2 conditions are met. I want a red ball when I have not received an invoice and the invoice due date is within 30 days. I know I'm close since I've gone from \"unparsable\" to \"incorrect…","snippet":"Formulas are the bane of my existence and I really need to take a class! Today I'm trying to set up a formula to throw a flag when 2 conditions are met. I want a red ball when I…","categoryID":322,"dateInserted":"2023-08-11T16:27:44+00:00","dateUpdated":null,"dateLastComment":"2023-08-11T17:49:45+00:00","insertUserID":120231,"insertUser":{"userID":120231,"name":"Pamela Wagner","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Pamela%20Wagner","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-08-11T17:47:38+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"},"updateUserID":null,"lastUserID":120231,"lastUser":{"userID":120231,"name":"Pamela Wagner","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Pamela%20Wagner","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-08-11T17:47:38+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":4,"countViews":59,"score":null,"hot":3383549849,"url":"https:\/\/community.smartsheet.com\/discussion\/108861\/if-and-formula","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/108861\/if-and-formula","format":"Rich","lastPost":{"discussionID":108861,"commentID":390268,"name":"Re: IF\/AND Formula","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/390268#Comment_390268","dateInserted":"2023-08-11T17:49:45+00:00","insertUserID":120231,"insertUser":{"userID":120231,"name":"Pamela Wagner","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Pamela%20Wagner","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-08-11T17:47:38+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Get Help","url":"https:\/\/community.smartsheet.com\/categories\/get-help"},{"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions"}],"groupID":null,"statusID":3,"attributes":{"question":{"status":"accepted","dateAccepted":"2023-08-11T17:48:48+00:00","dateAnswered":"2023-08-11T17:12:43+00:00","acceptedAnswers":[{"commentID":390261,"body":"
You were, indeed, very close.<\/p>
=IF([Invoice Received?]@row = 0, IF(AND([Renewal Date]@row >= TODAY(), [Renewal Date]@row <= TODAY(+30)), \"Red\"))<\/p>"},{"commentID":390264,"body":"