Risk assessment functions

Know where the business is exposed.

Syntax

Write the function's name and its arguments. The period is written one of three ways: a date window name such as ROLLING_90_DAYS (the date window functions), a start date and an end date such as "2026-01-01", "2026-03-31", or an accounting period id.

COMPUTE_RISK_SUMMARY and COMPUTE_DOMAIN_BREACH_FREQUENCY look at all events and take no period.

COMPUTE_RISK_SUMMARY(accountId, [fields])
COMPUTE_RISK_TREND(accountId, period, [periodEnd], [fields])
COMPUTE_DOMAIN_BREACH_FREQUENCY(accountId)
COMPUTE_AUDIT_LOG(accountId, period, [periodEnd], first, [after], [fields])
COMPUTE_RISK_SCORECARD(accountId, period, [periodEnd])
FINANCIAL_RISK_INTELLIGENCE(accountId, period, [periodEnd], [locationId])

Parameters and arguments

Arguments are written in brackets, separated by commas. An argument in square brackets is optional.

  • COMPUTE_RISK_SUMMARY

    accountId

    Required: Yes
  • fields

    Required: No
  • COMPUTE_RISK_TREND

    accountId

    Required: Yes
  • period

    Required: Yes
  • periodEnd

    Required: No
  • fields

    Required: No
  • COMPUTE_DOMAIN_BREACH_FREQUENCY

    accountId

    Required: Yes
  • COMPUTE_AUDIT_LOG

    accountId

    Required: Yes
  • period

    Required: Yes
  • periodEnd

    Required: No
  • first

    Required: Yes
  • after

    Required: No
  • fields

    Required: No
  • COMPUTE_RISK_SCORECARD

    accountId

    Required: Yes
  • period

    Required: Yes
  • periodEnd

    Required: No
  • FINANCIAL_RISK_INTELLIGENCE

    accountId

    Required: Yes
  • period

    Required: Yes
  • periodEnd

    Required: No
  • locationId

    Required: No

Examples

Average risk score, critical events, total money lost to events, and a six axis radar over the last 90 days.

Return type and behaviour

Each function returns one value. The table shows its type, what it does and one way to write it; the examples use the functions in realistic statements.

FunctionReturnsBehaviourForm
COMPUTE_RISK_SUMMARYrecordAverage risk score, critical events, total loss, enterprise value erosion and staff overrides across all eventsCOMPUTE_RISK_SUMMARY("ACCOUNT_ID")
COMPUTE_RISK_TRENDrecordThe daily risk score, money impact and event count, with the trend of the scoreCOMPUTE_RISK_TREND("ACCOUNT_ID", "ROLLING_90_DAYS")
COMPUTE_DOMAIN_BREACH_FREQUENCYrecordHow many medium, high and critical events each area of the business has raisedCOMPUTE_DOMAIN_BREACH_FREQUENCY("ACCOUNT_ID")
COMPUTE_AUDIT_LOGrecordA page of governance events, newest first, with chart ready seriesCOMPUTE_AUDIT_LOG("ACCOUNT_ID", "ROLLING_90_DAYS", 25)
COMPUTE_RISK_SCORECARDrecordA risk summary with a six axis radar built from refunds, discounts, stock, suppliers, margin leakage and capitalCOMPUTE_RISK_SCORECARD("ACCOUNT_ID", "ROLLING_90_DAYS")
FINANCIAL_RISK_INTELLIGENCErecordThe five CFO risk sections and a plain sentence that sums them upFINANCIAL_RISK_INTELLIGENCE("ACCOUNT_ID", "ROLLING_90_DAYS")

Every answer from COMPUTE_RISK_SUMMARY, COMPUTE_RISK_TREND, COMPUTE_DOMAIN_BREACH_FREQUENCY, COMPUTE_AUDIT_LOG and COMPUTE_RISK_SCORECARD also carries meta (the engine version, when it was computed and the function's name) and narratives, the written commentary stored for your account, newest period first.

COMPUTE_RISK_SUMMARY answers

FieldTypeMeaning
avgRiskScorenumberThe average risk score of all events
criticalCountwhole numberEvents of Critical severity
totalLossmoneyThe money impact summed over all events
totalEvErosionmoneyThe yearly rate of loss capitalised at the cost of capital: the value a business loses if the losses keep going
staffOverrideCountwhole numberEvents whose code is a staff override
metricLabels, metricValueslistsThe same five measures as chart labels and numbers

COMPUTE_RISK_TREND answers

FieldTypeMeaning
trendlist of recordsdate, riskScore, financialImpact and eventCount for each day with events
seriesDates, seriesRiskScores, seriesFinancialImpact, seriesEventCountslistsThe same days as parallel lists for a chart
riskScoreSlopenumberChange in the daily score per day. Present when at least 2 days have events and the score was asked for
riskScoreTrendlist of numbersThe fitted line for each day
riskScoreRsqnumberHow well a straight line fits the daily scores

COMPUTE_DOMAIN_BREACH_FREQUENCY answers

FieldTypeMeaning
domainslist of recordsdomain and count, the most breaches first
seriesDomainLabels, seriesBreachCountslistsThe same as parallel lists for a chart

COMPUTE_AUDIT_LOG answers

FieldTypeMeaning
edgeslist of recordsEach is cursor and node, where node holds the fields asked for: eventId, code, severity, riskScore, financialImpact, aggregateId, createdAt, detail
pageInforecordhasNextPage and endCursor
totalCountwhole numberEvents in the range
seriesDates, seriesSeverities, seriesRiskScores, seriesFinancialImpact, seriesCodeslistsThe page as parallel lists for a chart

COMPUTE_RISK_SCORECARD answers

FieldTypeMeaning
avgRiskScorenumberThe average risk score in the period
criticalEventswhole numberCritical events in the period
totalFinancialImpactmoneyThe money impact of the period's events
topRiskDomainslist of textThe three areas with the most events
riskRadarlist of recordsaxis and value for Refund Risk, Discount, Inventory, Supplier Risk, Margin Leakage and Capital Efficiency
radarLabels, radarValues, domainLabels, domainCountslistsThe radar and the domain counts as parallel lists

FINANCIAL_RISK_INTELLIGENCE answers

FieldTypeMeaning
cfoSummarytextOne sentence on profit, returns against the cost of capital, margin pressure, takeover exposure and concentration
financialHealthrecordeconomicProfit, nopat, roic, wacc, roicWaccSpread, waccCoverageRatio, waccCoverageLevel, breakEvenGap, breakEvenRevenue, investedCapital, ebit, revenue, grossProfit, totalFixedCosts
riskPressurerecorddiscountDependencyRate, discountCap, discountDependencyLevel, marginCompressionFlag, marginTrend (period, grossMarginRate), fixedCostBurdenRate, shippingLeakage, saasCost, saasCostRate, operatingLeverage
capitalValuationRiskrecordearningsStabilityCv, earningsStabilityLevel, revenueConcentrationTop1, revenueConcentrationHhi, enterpriseValueDelta, takeoverVulnerabilityScore, takeoverRiskLevel, tvsFactors (factor, triggered, points)
operationalRiskrecordgmroi, gmroiLevel, daysInventoryOutstanding, inventoryCapital, locationProfitability (one record for each location with revenue, margins and atRisk), customerRefundRate, customerQualityScore
forecastStressrecordforecastVsRequiredMargin, requiredMargin, forecastGapLevel, stressScenarios (label, revenueShock, stressedRevenue, stressedEbit, stressedEp), breakEvenRevenue, downsideEp
Errors and exceptions
ErrorWhat happenedHow to recover
HTQL-5001The function was given the wrong number of arguments. The message names the function and the countsGive it the arguments listed under Parameters
HTQL-1004 Unsupported functionThe name is not a function this engine runsCheck the name and its spelling against this entry
Limitations
  • COMPUTE_RISK_SUMMARY and COMPUTE_DOMAIN_BREACH_FREQUENCY cover every event, with no period. COMPUTE_DOMAIN_BREACH_FREQUENCY counts only medium, high and critical severity.
  • The enterprise value erosion in COMPUTE_RISK_SUMMARY uses a cost of capital of 12 per cent when no macro settings are stored.
  • A field list that names none of the known fields answers an empty record.
  • Severity labels are Low, Medium, High and Critical.
Permissions and security

These functions read your governance events, per order profit, refunds, order lines, inventory movements, settings and stored narratives. The caller needs read access to the records named, and nothing is written.

They are governed by the same read access as the tables they read, so no separate grant is needed beyond it.

Best practices
  • Name the fields you need in the summary, trend and audit calls: each field is a separate calculation.
  • Call COMPUTE_RISK_TREND before you act on a single bad day: one critical event can move a quarter's average.
  • Open FINANCIAL_RISK_INTELLIGENCE when the scorecard shows capital or margin pressure.