# Issue with countifs statement when there's an if statement

My countifs statement is this

=COUNTIFS({Tech 1}, \$Tech@row, {Start 1}, <=[6.00]\$1, {End 1}, >[6.00]\$1)

and the formula in the column it's looking in is this

=IF(AND(Split@row = 1, [Required Staff]@row > 1), IFERROR(LEFT([Tech 1 Hours]@row, FIND("-", [Tech 1 Hours]@row) - 1), [Start Time]@row), [Start Time]@row)

As long as the split value is =0, the countifs works, but if the split value is 1, it doesn't count it even if all the conditions are met

Am I missing something?

• Figured it out, One of the values was a text the other was a number. I had to convert the start and end columns to numbers using the values function.

Corrected Start Time Formula

=IF(AND(Split@row = 1, [Required Staff]@row > 1), IFERROR(VALUE(LEFT([Tech 1 Hours]@row, FIND("-", [Tech 1 Hours]@row) - 1)), [Start Time]@row), [Start Time]@row)

Corrected End Time Formula

=IF(AND(Split@row = 0, [Required Staff]@row > 1), [End Time]@row, IF(CONTAINS("-", [Tech 1 Hours]@row), IFERROR(VALUE(RIGHT([Tech 1 Hours]@row, 5)), [End Time]@row)))

😀

@Paul Newcome Thanks for looking at it

• What is in each the columns referenced in this portion?

IFERROR(LEFT([Tech 1 Hours]@row, FIND("-", [Tech 1 Hours]@row) - 1), [Start Time]@row)

• It is a time range of start and end times. For example 9.00-10.00. So the value I pull out of that equation is the start time of an activity.

for the end time, I have this

=IF(Split@row = 1, IFERROR(LEFT(SUBSTITUTE([Tech 1 Hours]@row + "-", JOIN([Tech 1 Start]@row:[Tech 1 Start]@row, "-") + "-", ""), FIND("-", SUBSTITUTE([Tech 1 Hours]@row + "-", JOIN([Tech 1 Start]@row:[Tech 1 Start]@row, "-") + "-", "")) - 1), [End Time]@row), [End Time]@row)

• This is the main sheet with the information

This is the sheet with the countifs

Right now it only is counting the rows where split is not checked. The idea of the split is that if a time point is from 8 to 10, we can have 1 person do 8 to 9 and the other do 9 to 10. We would input these times into the Tech hours columns as 8.00-9.00 & 9.00-10.00. Theses then would get split up in the tech start and end time columns which is what is used in the formula. If it's not split, both people are working 8 to 10.

When I uncheck the column, the data of the non split start and end time is calculated.

• I went even simpler and tested this formula with a cell that had a value of 10.00

=COUNTIF({start}, 10.00)

The result I got was 0

• Exactly how is the [Start Time] column populated?

• Figured it out, One of the values was a text the other was a number. I had to convert the start and end columns to numbers using the values function.

Corrected Start Time Formula

=IF(AND(Split@row = 1, [Required Staff]@row > 1), IFERROR(VALUE(LEFT([Tech 1 Hours]@row, FIND("-", [Tech 1 Hours]@row) - 1)), [Start Time]@row), [Start Time]@row)

Corrected End Time Formula

=IF(AND(Split@row = 0, [Required Staff]@row > 1), [End Time]@row, IF(CONTAINS("-", [Tech 1 Hours]@row), IFERROR(VALUE(RIGHT([Tech 1 Hours]@row, 5)), [End Time]@row)))

😀

@Paul Newcome Thanks for looking at it

• That's what I was thinking it would end up being. Glad you were able to figure it out.

## Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!
{"ft_lang_label":"__label__en","ft_lang_prob":0.84728414,"math_prob":0.97989964,"size":3254,"snap":"2023-40-2023-50","text_gpt3_token_len":1016,"char_repetition_ratio":0.16615385,"word_repetition_ratio":0.3584559,"special_character_ratio":0.32052857,"punctuation_ratio":0.13180515,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9972009,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-05T16:41:11Z\",\"WARC-Record-ID\":\"<urn:uuid:8c68d5f5-4ba6-4dec-8fca-c633e3eabc3b>\",\"Content-Length\":\"219353\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:80465e2c-98a7-4a4f-9c75-6254cafcb0ff>\",\"WARC-Concurrent-To\":\"<urn:uuid:d1b96500-51b5-4a3d-b08f-758ffe98cca7>\",\"WARC-IP-Address\":\"162.159.138.78\",\"WARC-Target-URI\":\"https://community.smartsheet.com/discussion/80622/issue-with-countifs-statement-when-theres-an-if-statement\",\"WARC-Payload-Digest\":\"sha1:PJPBNPIA64YGMGU7T3BPUMXNGJFAW5D2\",\"WARC-Block-Digest\":\"sha1:UQMCLQ7HB7VLW4J7A3RCGDE4466JTMPB\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100551.2_warc_CC-MAIN-20231205140836-20231205170836-00860.warc.gz\"}"}