Skip to content

Tgt - Forecasting end-of-month revenue and anticipating gaps

This use case illustrates a concrete use of the Biron plugin in Zapier. If you are not yet familiar with how it works (authentication, query structure, variable management), please read the Biron × Zapier guide first before continuing.


A Zap that triggers several times a month and sends a Slack update on revenue target progress for each store. Unlike the monthly summary which looks at the past month, this Zap projects end-of-month revenue to anticipate results.

The forecast combines already-realized revenue and an estimate of remaining revenue, calculated from Y-1 seasonality and recent growth — the same methodology as the monthly forecast Zap:

Projected end-of-month revenue = Realized revenue + Y-1 revenue (remaining month) × (1 + 3-month growth)

Achievability categories:

CategoryConditionEmoji
ValidatedTarget already reached✅
GuaranteedForecast > +15%🟣
Comfortable+5% to +15%🔵
On track0% to +5%🟢
Short-5% to 0%🟡
Ambitious-15% to -5%🟠
At risk< -15%🔴

For stores At risk, a gap analysis is automatically generated in thread via the gap analysis sub-Zap.


Schedule → Date calculation → Store query → Formatting → Slack → Loop (Filter → Sub-Zap)

Configure a Schedule by Zapier block according to the desired frequency for the month-to-date tracking — for example twice a week or every Monday.


Biron queries require explicit dates. This block generates them dynamically on each run.

Add a Code by Zapier block (Python). Use the following prompt to generate the code, then paste the result into the block:

Role: Python expert for Zapier.
Goal: Create a relative date calculation script.
Calculate the following dates, handling calendar edge cases
(leap years, end of month):
- Start of current month and Y-1
- End of current month and Y-1
- Yesterday and yesterday Y-1
- 3 months ago and 3 months ago Y-1
Output: return an "output" dictionary with all dates in YYYY-MM-DD format.

Create a per-store chart in Biron retrieving the following four metrics, then copy the NexusQL and paste it into the Biron Query block. Replace the static dates with the variables produced in the previous step.

MetricRole in the forecast
Revenue excl. VAT current monthRealized to date
Revenue excl. VAT Y-1 (remaining month)Seasonality base for the remaining portion
Revenue excl. VAT growth last 3 monthsRecent momentum signal
Revenue excl. VAT target full monthTarget to evaluate

Then add the following calculated columns directly in the query:

-- Projected end-of-month revenue
ROUND(
`CA HT Mois en Cours` + `CA HT (A-1) Mois restant` * `Croissance CA HT 3 derniers mois`,
2
) AS `Objectif Prévisionnel CA HT`,
-- Gap between forecast and target (in %)
ROUND(
100 * (`Objectif Prévisionnel CA HT` - `Objectif CA HT`) / `Objectif Prévisionnel CA HT`,
2
) AS `Delta Pourcent Prévisionnel CA HT`,
-- Achievability category
CASE
WHEN `CA HT Mois en Cours` >= `Objectif CA HT` THEN 'Validé'
WHEN `Delta Pourcent Prévisionnel CA HT` < -15 THEN 'Compromis'
WHEN `Delta Pourcent Prévisionnel CA HT` < -5 THEN 'Ambitieux'
WHEN `Delta Pourcent Prévisionnel CA HT` < 0 THEN 'Court'
WHEN `Delta Pourcent Prévisionnel CA HT` < 5 THEN 'Attendu'
WHEN `Delta Pourcent Prévisionnel CA HT` < 15 THEN 'Confortable'
ELSE 'Garanti'
END AS `Prévision Objectif`

Biron data must be converted into a readable Slack message. Add a Code by Zapier block (Python) and use this prompt to generate the code:

Role: Python expert for Zapier.
Goal: Generate a Slack month-to-date target tracking message.
Available inputs (via input_data):
- shops: store names (comma-separated list)
- labels: category of each store (comma-separated list)
- billing_target: revenue target (comma-separated list)
- billing_real: realized revenue since start of month (comma-separated list)
Request:
1. Format all amounts in euros using French number format:
thousands separator = space, decimals = comma (e.g. 12 345,67€).
2. Group stores by category in this order, with the associated emoji:
✅ Validated | 🟣 Guaranteed | 🔵 Comfortable | 🟢 On track | 🟡 Short | 🟠 Ambitious | 🔴 At risk
Unknown categories go into a ⚪ "Uncategorized / Other" group at the end.
3. For each store, display:
• *Store name*: _Realized_ 12 345,67€ | _Target_ 15 000,00€
If the category is not Validated, add the remaining gap: | -2 654,33€
(if the gap is positive, display 0).
4. Generate a Slack message slack_message_formatted with:
- Bold title: *Target Tracking {Month} {Year} as of {DD/MM/YYYY}*
- Italic subtitle: "Comparison between realized revenue since start of month and the target."
- Store groups (empty categories not displayed)
5. Return the result in output with the key slack_message_formatted.

Add a Slack block and configure:

  • Channel: the channel where the tracking update should be sent
  • Message Text: the slack_message_formatted variable produced by the formatting block

Add a Looping by Zapier block, passing it the store names and their Prévision Objectif from the query.

The loop iterates over each store and executes the following two steps for each of them.


Add a Filter block with the following condition:

  • Continue only if Prévision Objectif equals Compromis

Other categories are stopped here — either the store is on the right track, or it has already validated its target.


For each store At risk, trigger the gap analysis sub-Zap by passing the four expected variables:

VariableValue to pass
start_dateStart of current month (date calculation step)
end_dateYesterday (date calculation step)
shop_idStore name or identifier (current loop iteration)
slack_tsTS of the Slack message sent in the previous step

On each run, your team receives a Slack status update on current month target progress. Stores whose trajectory is at risk automatically receive a gap analysis in thread — early enough in the month to course-correct.