Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9842

How can gaps be quantified within a combined set of variable arrays?

$
0
0

I'm using Google Sheets to build a crop planning tool for farmers (kinda like a gantt chart). I need help quantifying the number of days within a given timeframe that no crops are planted in a bed. In the end, I want to be able to be able to reference a single bed by name within the table (e.g. Bed 1 or NW4) and know the total number of "unplanted" days for that bed.

The user of the spreadsheet determines...

  • the number of crops within a bed
  • the start date of each crop (planting)
  • the finish date of each crop (harvest)

My problem solving attempts have followed these steps without success:

  1. Calculate timeframe by subtracting final harvest (MAX) by first planting (MIN) across all beds
  2. Filter by bed name (e.g. NE1)
  3. Create one or many arrays of dates using the start date and end date for each crop
  4. Combine & flatten arrays
  5. Count number of unique dates

Since it is possible for dates/arrays to overlap I thought the =UNIQUE(FLATTEN(range) formula would be useful (total days - unique days = unplanted days); however, step 2 is proving to be especially difficult. I can't figure out how to make a combined array that's extrapolated from a variable array. Ya dig?

The images below are only meant to be visual representations of the examples.

Example 1: a single crop (green) is planted leaving a total of 5 days "unplanted" (red).

enter image description here

Example 2: two crops are planted leaving gaps in the middle and the ends.

enter image description here

Example 3: many crops are planted and many overlap leaving gaps in the beginning and middle.

enter image description here

Here's a working model of the crop planning tool but I haven't made any meaningful progress on the question above:

https://docs.google.com/spreadsheets/d/1oJtPamAb6uZbz42pjUOu6X9QMICalvmJZg7WziPusVk/edit?usp=sharing

BONUS: I'd be curious to see a version that uses "transplant date" as the start date if present.


Viewing all articles
Browse latest Browse all 9842

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>