Skip to main content
Your Analytics credential can run arbitrary read-only SELECT queries over reporting.*. SQL uses the same relations as Power BI, but each query chooses its own grain, joins, filters, and result. Read Relationships and data model before combining repeating detail.

Use this process

For each question:
  1. Define what one result row should represent.
  2. Choose the relation with that grain.
  3. Join ownership through entity_id or component_id.
  4. Traverse explicit relationship views when the question crosses independent objects.
  5. Use EXISTS for detail that only filters the result.
  6. Pre-aggregate detail before combining measures from different grains.
  7. Validate codes, roles, currency, units, dates, nulls, and known records.
Do not begin with shipments or one_off_quotes by habit. Begin with the relation that matches the answer.

Choose the starting grain

Use a wide convenience view only when the report intentionally uses one subtype and its columns.

Example 1: Inventory current entities

This query starts from business_entities because one result row summarizes one entity type:
This includes recognized shipments, quotes, bookings, and consols without merging them into one business fact. entity_type keeps their meaning explicit. Add subtype business numbers only when needed:
Only the matching subtype relation contributes a business number.

Example 2: Analyze charge lines

This query starts from entity_charges because the result measures charges, not entities:
The currency remains part of the grouping. Do not sum amounts across currencies. Add entity-level information without changing the charge grain:
FRT is illustrative. Inspect your organization’s observed codes before creating a recurring query.

Example 3: Traverse explicit relationships

This query resolves both endpoints through entity_identities. It keeps the observer separate:
One logical relationship can have several evidence rows. Deduplicate the endpoint pair when the question needs one business edge:
To traverse a packing-line reference to its resolved container:
The component query uses the explicit component edge. It does not join a packing line to a container because their displayed container numbers happen to match.

Filter entities without multiplying them

Use one EXISTS block for each repeating relation that only determines eligibility:
Replace the example date and role codes with values observed in your data.

Pre-aggregate detail measures

If a result needs both entity and detail measures, reduce the detail to one row per entity_id before joining:
The result grain is one entity type and currency combination.

Inspect codes before filtering

CargoWise roles and codes can differ by organization:
Inspect descriptions and names when a code is unfamiliar. Use stable source codes in recurring queries after confirming their meaning.

Validate the result

Before sharing an answer, check:
  • the result still has the intended grain
  • every join uses a documented key
  • entity relationships come from explicit edges
  • codes and roles mean what the business question expects
  • currencies are not mixed
  • normalized units are populated for measured rows
  • local dates and UTC dates are not mixed without a rule
  • null and unsupported values remain visible
  • a few known CargoWise records produce the expected result
If the required value is not in a typed relation, continue to Discover fields.