§ Lesson 07 / Best Practices

Eight rules for analysts who don’t want to silently break.

Practical query & reporting habits for working with FOCUS datasets. They apply whether you’re using raw SQL, a BI tool, or a vendor solution that allows custom reports.

1 — Start simple

Start simply before adding complexity, especially before applying aggregations like SUM(BilledCost). Ask “what question am I trying to answer?” Apply one filter at a time, look at the results, build understanding.

Gall’s Law: Complex working systems evolve from simple working systems. Complex systems built from scratch don’t work.

2 — Validate results

3 — Use appropriate filters

Prefer normalized columns — they work consistently across all data generators.

GoalNon-optimalOptimal
Find usage charges (excluding credits)WHERE BilledCost > 0WHERE ChargeCategory = 'Usage'

4 — Use negated filters

When you filter for “all costs related to X,” also run the negated filter to see what you’re excluding. This catches misclassifications and confirms your filter actually makes sense.

FILTER (WHERE ServiceName != 'VirtualMachineService')

5 — Avoid SUBSTRING matching (LIKE)

Substring matching is fragile — results are dynamic. If a charge description changes (which providers do without warning), your filter silently breaks. Use a more specific filter when one is available.

Non-optimalOptimal
WHERE ChargeDescription LIKE 'VM Usage%'WHERE ServiceName = 'VirtualMachineService'

6 — Use DISTINCT or GROUP BY

Prefer GROUP BY when both work — it gives you aggregation flexibility.

7 — Gather feedback

Start every query project with a 15-minute conversation:

Share interim results: “here’s one day, does this align with your expectations?” When presenting, show row counts, explain filters, highlight surprises.

8 — Be mindful of date ranges

Composing the practices

These don’t live in isolation. A typical query layered them all:

SELECT
    ServiceName,
    ConsumedUnit,
    SUM(BilledCost) / NULLIF(SUM(ConsumedQuantity), 0) AS CostPerUnit,
    SUM(ConsumedQuantity) AS TotalQuantity,
    COUNT(DISTINCT ResourceId) AS ResourceCount
FROM focus_data
WHERE ChargeCategory = 'Usage'
  AND ChargePeriodStart >= '2026-04-01T00:00:00Z'
  AND ChargePeriodStart <  '2026-05-01T00:00:00Z'
  AND BillingCurrency = 'USD'
  AND ConsumedQuantity > 0
GROUP BY ServiceName, ConsumedUnit
ORDER BY CostPerUnit DESC
LIMIT 100;

Beyond the eight — supplementary practitioner notes

Allocation

Unit economics

The recurring lesson: make unit cost visible at general availability, not retroactively. Pick the right unit per industry — per request, per customer, per CI minute, per AI inference, per vehicle, per GB stored.

FinOps for AI

Anti-patterns to avoid

Knowledge check

Q. Last quarter you wrote a report that pulls all virtual-machine charges using WHERE ChargeDescription LIKE 'VM Usage%'. It worked perfectly until the provider quietly renamed the description text to "Compute Usage" in their April release notes. You don’t notice. What does your April report show, and what should you have done?

Silent zero. ChargeDescription is a vendor-controlled string; providers can rewrite it without notice. Substring/LIKE filters look stable until the day they aren’t, and the failure mode is silent — no error, just wrong numbers. Always prefer normalized columns (ServiceName, ChargeCategory, PricingCategory) for filters that need to survive vendor wording changes.