dax-sql a compiler for semantic models

Bugs

Bugs dax-sql found in the engines and specs it compiles to, each reported upstream with the smallest query that shows it. Fixed means closed as completed on GitHub.

Loading…

Limitations

dax-sql returns the same answers as Power BI, except in the cases below. All of them are by design: dax-sql follows plain SQL rules there, not Power BI's. They are not bugs, and they will not be "fixed".

By design, always

  1. Text is case-sensitive. "Red" and "red" are two different values. Power BI treats them as one.
  2. Text sorts by the engine's rules. On DuckDB that is character code order, not Power BI's language-aware order.
  3. Trailing spaces count. "a " and "a" are two different values. Power BI removes trailing spaces when it loads data.
  4. The blank row only next to a fact's measures. Sales whose key is missing from a dimension show as a blank group when sales are measured by that dimension's columns. A list of the dimension's values (VALUES, ALL) has no blank row.
  5. A column that mixes numbers and text comes back as text.
  6. IFERROR returns its first argument. SQL has no error values.
  7. PATH walks at most 32 levels. A row deeper in its hierarchy gets a blank path. SQL plans have no recursion, so the levels are fixed.
  8. Values come back unformatted. Applying a measure's format string is up to you. FORMAT works in English (en-US) with a fixed pattern only.

By design, on Microsoft Fabric (T-SQL) only

  1. 1 / BLANK() is blank, not infinity. T-SQL has no infinity.
  2. Sums of floating-point numbers are computed exactly, so they can differ from Power BI's in the last digit.

DAX and Ossie SQL differ, by design

  1. A blank in arithmetic: DAX treats it as 0 ([Sales] - [Returns] is Sales). SQL keeps it: NULL + 1 is NULL.
  2. A count of no rows: blank in DAX, 0 in SQL.
  3. Fixed decimals: DAX rounds to 4 places. SQL does not round.
  4. Distinct counts: DAX counts a blank as a value. SQL's COUNT(DISTINCT) skips NULL.

Not supported

Anything not listed in DESIGN.md. dax-sql then stops with an UNSUPPORTED error. It never returns a guessed answer.

Every question in SQL is a new query

SQL gives the exact answer, but each question is written from scratch, joins and all.

What you write

The answer

SQL over the model (SELECT Color, AGG("Sales Amount") FROM contoso GROUP BY ALL: a measure by its name, no joins), or DAX, answered by DuckDB in this tab.

The answer

The compiler on each engine

The conformance suite's queries, each answered by Power BI, compiled by dax-sql and run on each engine (the latest CI run of each). Differs: every query whose answer is not Power BI's (other rows, an error, or unsupported), then why.
EngineMatchDiffersDesignNot yetEngineFlakyUnexplained

Choose an engine to see the queries it does not answer as Power BI does.

About

dax-sql is a compiler for semantic models. A DAX query, or an Apache Ossie SQL query, goes in, with a Power BI (TMSL) or Ossie model. One SQL SELECT comes out, for DuckDB or Microsoft Fabric. It has no dependencies and is MIT licensed. It was initially written by N.S. Devaraj.

npm install dax-sql
import { createCompiler } from 'dax-sql';
import { tmslToModel } from 'dax-sql/formats/tmsl.js';   // or formats/ossie.js

const model = tmslToModel(JSON.parse(bimText));           // a model.bim
const dax = createCompiler(model, { tableSource: t => `read_parquet('data/${t.name}.parquet')` });
const { sql, columns } = dax.compile(`EVALUATE SUMMARIZECOLUMNS('Date'[Year], "Sales", [Sales Amount])`);

The full design, with every rule it implements, is in DESIGN.md.

This page

One HTML file. Apart from the SQL labelled hand-written, every SQL snippet on it is compiled in your browser by the compiler from the main branch, and run, when you ask, by DuckDB-WASM 1.32.0. The layout follows ossie_bench.

Not endorsed

Nothing here is endorsed by Microsoft or the Apache Software Foundation. Power BI and DAX are Microsoft's; Apache Ossie is an incubating project of the ASF.