If you’ve been tackling the Alteryx Community Weekly Challenges, you know they can range from simple data prep to complex spatial and predictive analytics. Today, we're breaking down a iterative problem: Weekly Challenge #123.
This challenge is a fantastic exercise in using iterative macros to simulate population dynamics over time.
The Problem Statement
The core of this challenge requires us to simulate two growing populations, humans and a new breed of rabbits.
"In what future month will a new breed of rabbits to exceed the human population 2:1?"
To figure this out, we have a few moving pieces and specific rules to follow:
- We will start with 1 female and 1 male rabbit born today (0 months old).
- Each month, each female produces a litter of 4 bunnies: 1 male and 3 females.
- A female cannot start to reproduce until she has matured to 4 months of age.
- All rabbits live only to 24 months in age (Alive months 0-23, die on the start of the 24th month).
- The human population grows at a rate of 0.058% per month.

To begin our flow we bring in a text input and convert it to a Macro input. Next we use a Select tool to ensure are data types are correct. This is then followed by a Formula tool which increments the Date, Human Population and Age.


After we've incremented our data we filter out the dead bunny's from what we have left and split the rabbits based on whether they are mating or not ([Age] >= 4).
Next is a Summarise tool to find our total number of reproducing rabbits followed by a Formula tool which creates a new row containing our new born bunny's.
We then Union this new row back on to the rest of our data flow.



For our solution we need the total rabbit population. To get that we sum the female and male populations then append them back to the main flow.
As you can see in our data above we currently have [Null] values for three of our fields which can be replaced by filling down with Multi-Row Formula tools. Afterwards is another Formula to sum are two population totals to find the overall rabbit count.

Following this is a Filter tool splitting our flow on the condition that the rabbit population is 2x greater then our human population. This leads to our two outputs, the top one being our final solution output and the bottom being sent back in to repeat the loop.

This workflow is a brilliant example of how Alteryx handles complex, rules-based iterations. By breaking down the lifespan, breeding rules, and growth rates into sequential tools, we transform a tricky math problem into a highly visual, logical data stream.


