Tgt - Ranking stores and explaining end-of-month 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.
What we’re building
Section titled “What we’re building”A Zap that triggers on the 1st of each month and produces two things:
- A Slack summary message ranking each store by performance level for the past month
- Gap analysis threads for stores with extreme results — those that overperformed or failed — generated via the gap analysis sub-Zap
Performance levels are defined as follows:
| Level | Threshold | Emoji |
|---|---|---|
| Incredible | ≥ 140% of target | 🚀 |
| Success | 100% to 140% | 🟢 |
| Failure | 90% to 100% | 🟠 |
| Disaster | < 90% | 🔴 |
Zap architecture
Section titled “Zap architecture”Schedule → Date calculation → Store query → Formatting → Slack → Loop (Filter → Sub-Zap)Trigger — Schedule by Zapier
Section titled “Trigger — Schedule by Zapier”Configure a Schedule by Zapier block:
- Frequency: Every Month
- Day: 1
- Time: 9:00 AM
Date calculation
Section titled “Date calculation”Biron queries require explicit dates. This block dynamically generates the boundaries of the previous month 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 previous month- End of previous month
Output: return an "output" dictionary with all dates in YYYY-MM-DD format.Store query — target achievement rate
Section titled “Store query — target achievement rate”Create a per-store chart in Biron retrieving the target achievement rate for the previous month. Copy the NexusQL, paste it into the Biron Query block and replace the static dates with the variables produced in the previous step.
Then add the following calculated column directly in the query to categorize each store:
CASE WHEN `% Atteint Objectif CA HT` < 0.90 THEN 'Catastrophe' WHEN `% Atteint Objectif CA HT` < 1 THEN 'Echec' WHEN `% Atteint Objectif CA HT` < 1.40 THEN 'Réussite' ELSE 'Incroyable'END AS result_tierFormatting — summary message
Section titled “Formatting — summary message”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 summary message of store performanceagainst their targets for the previous month.
Available inputs (via input_data):- stores: store names (comma-separated list)- targets: target achievement rate in % (comma-separated list)- tiers: performance category (comma-separated list)
Request:1. Automatically calculate the name of the previous month and the year.2. Group stores by category in this order, with the associated emoji: 🚀 Incredible | 🟢 Success | 🟠 Failure | 🔴 Disaster Unknown categories go into a ⚪ Others group displayed last, with the original category in parentheses.3. For each store, display: ▪️ Store name: 97%4. Generate a Slack message slack_message with: - Bold title: *📊 Store Target Summary - {Month} {Year}* - Store groups with category names in uppercase - Empty categories are not displayed5. Return the result in output with the key slack_message.Send — Slack
Section titled “Send — Slack”Add a Slack block and configure:
- Channel: the channel where the summary should be sent
- Message Text: the
slack_messagevariable produced by the formatting block
Loop — Looping by Zapier
Section titled “Loop — Looping by Zapier”Add a Looping by Zapier block, passing it the store names and their result_tier from the query.
The loop iterates over each store and executes the following two steps for each of them.
Filter — Filter by Zapier
Section titled “Filter — Filter by Zapier”Add a Filter block with the following condition:
- Continue only if
result_tieris among:Incroyable,Echec,Catastrophe
Stores in Réussite are stopped here — their result is on track and does not require deeper analysis.
Launch sub-Zap — gap analysis
Section titled “Launch sub-Zap — gap analysis”For each store that passes the filter, trigger the gap analysis sub-Zap by passing the four expected variables:
| Variable | Value to pass |
|---|---|
start_date | Start of previous month (date calculation step) |
end_date | End of previous month (date calculation step) |
shop_id | Store name or identifier (current loop iteration) |
slack_ts | TS of the Slack message sent in the previous step |
Expected result
Section titled “Expected result”On the 1st of each month at 9 AM, your team receives a Slack summary of the past month. Stores with extreme results — either overperforming or struggling — automatically receive a gap analysis in thread, explaining the causes of the result and potential action levers.