npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dax-sql

v0.1.4

Published

A DAX to SQL compiler for Tabular (TMSL) semantic models, with DAX semantics; tested on DuckDB

Readme

dax-sql

A DAX to SQL compiler for Power BI / Tabular semantic models: a DAX query in, one SQL SELECT out, with DAX's semantics. Tested on DuckDB against Power BI's own answers. No dependencies.

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 for Apache Ossie

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])
  ORDER BY 'Date'[Year]`);
// sql: one SELECT for the engine; columns: [{ name: 'Year', type: 'int', ... }, { name: 'Sales', ... }]
  • In: a semantic model as dax-sql's model object (DESIGN.md; formats/ reads one from a TMSL model.bim or an Apache Ossie model whose metrics are DAX), a DAX query or a SQL SELECT over the model, options (DESIGN.md); or any SQL with SELECTs over the model as relations in it.
  • Out: one SQL SELECT and its columns; for a statement, its SQL with each of them compiled in place.
  • Errors: SYNTAX, SEMANTIC, UNSUPPORTED.
  • Tested: against Power BI's own answers, in conformance/.

Not implemented

  • Object-level security, dynamic format strings, the window functions' reset argument, and anything not listed in DESIGN.md.
  • FORMAT is en-US only, with a constant pattern; model format strings are not applied.
  • DATEDIFF with WEEK counts Sunday week boundaries.

Departures from DAX, by design

  • Text is case-sensitive in grouping, DISTINCT, sorting (by code point, not culture) and relationships; comparisons, IN and table filters are not, as in DAX.
  • Text keeps its trailing spaces (Power BI drops them on load): "a " and "a" are two values, in grouping, filters, relationships and LEN. Trim them in the data if they matter.
  • A column that mixes numbers and text comes back as text.
  • IFERROR returns its first argument: SQL has no error values.
  • A query that reads one table only (VALUES(Customer[City]), a slicer's list) has no blank row, though fact rows have keys the table lacks: it is a plain SELECT DISTINCT.