How one field reaches one bar

Tracing the Category label and Sales measure through an example Rayfin project

1 · The app authors the DAX App code

EVALUATE
SUMMARIZECOLUMNS(
    'DimProductCategory'[EnglishProductCategoryName],
    /*__FILTER_ARGUMENTS__*/
    "Sales", [Total Sales],
    "Orders", [Order Count],
    "Margin", [Gross Margin]
)
ORDER BY [Sales] DESC, ...

The grouping column becomes one row per category. "Sales" is an alias the author picks for the [Total Sales] measure.

The marker comment is where the app's own code inserts slicer and cross-filter arguments before sending.

2 · Rayfin returns a plain table Rayfin connector

{ status: "success",
  table: {
    columns: [
      { name: "DimProductCategory[EnglishProductCategoryName]" },
      { name: "[Sales]" },
      { name: "[Orders]" }, { name: "[Margin]" }
    ],
    rows: [
      [ "Bikes", 1773771.81, 1135, 0.407 ],
      [ "Accessories", 65783.35, 1737, 0.626 ],
      [ "Clothing",    34805.13,  770, 0.395 ]
    ] } }

The connector's job ends here: column names as the engine reports them, plus rows as arrays aligned to columns.

  • Grouping column: Table[Column]
  • Measure alias: [Alias]
  • No chart roles, display names, or formats yet

3 · The app renames and labels columns App code

columnMetadata: {
  "DimProductCategory[EnglishProductCategoryName]":
      { name: "Category", displayName: "Category" },
  "[Sales]":
      { name: "Sales", displayName: "Net sales",
        format: "$#,0.00;($#,0.00);$0.00" },
  ...
}
// toDataTable: columns.map(c => columnMetadata[c.name] ?? { name: c.name })
// rows pass through unchanged

A lookup keyed by the exact returned name swaps in a short field name, a display name and a format string. Row values are not touched.

If a key doesn't match, the raw name passes through and the app's helpers that look up Category throw a missing-column error rather than guess.

4 · A Vega-Lite spec names the fields App code

"mark": { "type": "bar" },
"encoding": {
  "y": { "field": "Category", "type": "nominal",
         "sort": "-x" },
  "x": { "field": "Sales", "type": "quantitative" },
  "tooltip": [
    { "field": "Category" },
    { "field": "Sales", "title": "Net sales",
      "format": ",.2f" }, ...
  ] }

The binding is by name, written by hand: the spec refers to the renamed fields from step 3. Nothing infers that categories go on an axis.

The sort, axis titles and tooltip formatting are also authored here.

5 · React renders the visual App code Visual library

The app's React component passes the table and spec to VegaVisual, which turns each row into a datum keyed by field name, so "Bikes" becomes a y-axis label and 1773771.81 sets the bar length.

The header text, the empty-state check, and the click and right-click wiring are app code around the visual.

6 · Same mechanics, one row, four cards App code Visual library

ROW( "Sales", [Total Sales],
     "Margin", [Gross Margin],
     "Orders", [Order Count],
     "AOV", [AOV], ... )   // 14 aliases

// connector → "[Sales]", toDataTable → "Sales"
cards.map(card => <KpiCard
  value={metric(table, card.name)} />)
Net sales
$1.9M
Sales
Gross margin
41.4%
Margin
Orders
2,192
Orders
Avg order value
$855.09
AOV

One query, one returned row. The app picks values by name for each card; comparison text such as SalesCompare ("+5.2% vs Nov 2013") comes from the same row.