Skip to content

Commit a42a5c5

Browse files
committed
First draft of DaxLib documentation
1 parent 3fc35aa commit a42a5c5

6 files changed

Lines changed: 123 additions & 7 deletions

File tree

_mydocs/contribute/index.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,52 @@ title: Contribute to DAX Lib
44
menu_title: Contribute
55
published: true
66
date: 2025-08-14
7-
modified: 2025-08-14
7+
modified: 2025-08-25
88
order: /02
99
next_reading: true
1010
---
11+
12+
A DAX library is deployed as a package in DAX Lib. A package is a ZIP file that includes a few files (**TODO add package description**).
13+
14+
You can follow these steps to add a new package to DAX Lib:
15+
16+
1. **Clone** the GitHub repository [https://github.com/sql-bi/daxlib/](https://github.com/sql-bi/daxlib/).
17+
18+
2. **Create a folder** for your package in `/packages/`, for example by copying the daxlib.sample package.
19+
20+
a. Name the folder after your package using lowercase names (e.g., `test.functions`), while the package should have a pascal naming convention (e.g., `Test.Functions`).
21+
22+
b. The package and library name is the prefix of all the function names. For example, to functions `Sum` and `Multiply` in the `Test.Functions` library package should be named `Test.Functions.Sum` and `Test.Functions.Multiply`.
23+
24+
c. The package and library name must have a hierarchical nomenclature, where the first name is the published/author identifier and the second (and following) names identify the library scope. For example, `Contoso.Conversion` is a library of conversion functions made by Contoso, whereas `Northwind.Math.Geometry` is a set of geometrical mathematical functions made by Northwind.
25+
26+
d. Do not use `Dax.` in the name of the library (Dax as a single word is a reserved keyword in a function name).
27+
28+
e. `DaxLib.` as a prefix is a reserved word for public open-source libraries of common use that are reviewed and approved by DaxLib maintainers. Do not create pull request for new `DaxLib.` libraries.
29+
30+
f. The first level in the folder structure is a single letter corresponding to the first letter of the package name (for example, a package `test.functions` will be in `/packages/t/test.functions/` folder). This is a technique used to reduce the number of elements in a single folder.
31+
32+
g. All the names of folders and files must be lowercase; the name of the package (with uppercase letters if necessary) is defined in the metadata (`manifest.daxlib` file) of the package.
33+
34+
3. **Create the DAX functions** in `functions.tmdl`
35+
36+
a. The file `lib/functions.tmdl` contains the source code of the DAX functions in a TMDL createOrReplace command. For example, in `test.functions` the name is `/packages/t/test.functions/lib/functions.tmdl`
37+
38+
b. The `functions.tmdl` file contains the function definition using the TMDL syntax following the `createOrReplace` statement
39+
40+
c. Include mandatory annotations for each function of the library:
41+
42+
annotation DAXLIB_PackageId = <name of library>`
43+
annotation DAXLIB_PackageVersion = <version of library>
44+
45+
4. **Create the manifest** in the `manifest.daxlib` file
46+
47+
a. For example, in `test.functions` the name is `/packages/t/test.functions/manifest.daxlib`
48+
49+
b. The `manifest.daxlib` file includes the properties of the package in JSON format. See [https://daxlib.org/package/DaxLib.Sample/#code](https://daxlib.org/package/DaxLib.Sample/#code) to get an example
50+
51+
5. **Create a pull request** to publish the library on daxlib.org
52+
53+
a. The pull request must be approved manually by DaxLib owners/maintainers.
54+
55+
b. When the pull request is approved, the package is immediately published.

_mydocs/integrate/index.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ title: Integrate DAX Lib with Third-Party Tools
44
menu_title: Integrate
55
published: true
66
date: 2025-08-14
7-
modified: 2025-08-14
7+
modified: 2025-08-25
88
order: /03
99
next_reading: true
1010
---
1111

12+
[DaxLib.Client](https://www.nuget.org/packages/DaxLib.Client) is the NuGet package that can be used by external tools to integrate with [DaxLib](https://daxlib.org) directly:
13+
- Create packages
14+
- Download packages
15+
16+
**NOTE**: Currently, the client does not add the functions to the semantic model, the external tool does that (like Tabular Editor). However, this feature will be added soon in the client before the integration with [Bravo for Power BI](https://bravo.bi).

_mydocs/user-guide/add-to-power-bi.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ layout: page
33
title: Add to Power BI
44
published: true
55
date: 2025-08-14
6-
modified: 2025-08-14
6+
modified: 2025-08-25
77
order: /user-guide/02
88
---
9+
10+
When you click the **Add to Power BI** button, you can copy the DAX library code to your clipboard and then paste it into the TMDL View of your Power BI semantic model.
11+
12+
1. *(optional)* With the **Show Code** button, you can view the code of the library before clicking **Copy** . This way, you can inspect the library code before moving forward.
13+
14+
2. After you click **Copy**, the code will be copied to your clipboard.
15+
16+
3. In Power BI, **open the TMDL View** of your semantic model.
17+
18+
4. In the TMDL view, and **paste** the code into the editor (CTRL+V).
19+
20+
5. Click **Apply** in the TMDL View.
21+
22+
6. Done! You can start using the functions in any DAX expression of your semantic model.

_mydocs/user-guide/getting-started.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ layout: page
33
title: Getting Started
44
published: true
55
date: 2025-08-14
6-
modified: 2025-08-14
6+
modified: 2025-08-25
77
order: /user-guide/01
88
---
9+
10+
1. **Find the library** you want using the search and browse features on [DAX Lib](https://daxlib.org).
11+
12+
2. Use the **view code** feature to view the content of a DAX library.
13+
14+
a. Use **F1** to open the command palette
15+
16+
b. Use **Collapse All** to collapse all expanded code blocks and see only the function names.
17+
18+
c. Use **Find** to look for a specific function name or description.
19+
20+
3. Use **Add to Power BI** to copy the DAX library code to add to your semantic model.

_mydocs/user-guide/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ layout: page
33
title: User Guide
44
published: true
55
date: 2025-08-14
6-
modified: 2025-08-14
6+
modified: 2025-08-25
77
order: /01
88
next_reading: true
99
---
1010

11-
This document provides a collection of user guides for the DAX Lib services. These guides are designed to help you understand how to use the various features and functionalities of DAX Lib effectively.
11+
This document provides a collection of user guides for the DAX Lib services. These guides are designed to help you understand how to use the various features and functionalities of DAX Lib.

_mydocs/what-is.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,47 @@ layout: page
33
title: What is DAX Lib?
44
published: true
55
date: 2025-08-14
6-
modified: 2025-08-14
6+
modified: 2025-08-25
77
order: /001
88
next_reading: true
99
---
10+
11+
DAX Lib is a website designed to distribute libraries of DAX user-defined functions (UDF). Similar to NuGet, DAX Lib provides a centralized platform where users can discover, share, and download reusable DAX function libraries to enhance their Fabric, Power BI, and Analysis Services semantic models.
12+
13+
# DAX libraries
14+
A DAX library is a collection of DAX user-defined functions that can be reused across different semantic models, promoting best practices and reducing duplication of effort.
15+
16+
## Functions designed for DAX libraries
17+
A DAX user-defined function is candidate for a library if it is model-independent, which means that it has no references to specific tables, columns, or measures within a particular model. When a function has direct dependencies on model elements, it is not suitable for inclusion in a DAX library and must be refactored to remove those dependencies.
18+
19+
Example of a **model-independent function**, good candidate for a DAX library:
20+
```DAX
21+
    FUNCTION RangeLookup = (
22+
            search : SCALAR VAL,
23+
            lookupTable : TABLEREF EXPR,
24+
            colMin : COLUMNREF EXPR,
25+
            colMax : COLUMNREF,
26+
            colTarget : COLUMNREF
27+
        ) =>
28+
        SELECTCOLUMNS (
29+
            FILTER ( 
30+
lookupTable, 
31+
colMin <= search && colMax > search 
32+
),
33+
            "@Result", colTarget
34+
        )
35+
```
36+
37+
Example of a **model-dependent function**, which could be defined in a semantic model to simplify the consumption of a generic function imported from a DAX library:
38+
```DAX
39+
    FUNCTION PriceLookup = (
40+
            search : SCALAR VAL
41+
        ) =>
42+
        RangeLookup (
43+
            search,
44+
            'Price Range',
45+
            'Price Range'[Min],
46+
            'Price Range'[Max],
47+
            'Price Range'[Range]
48+
        )
49+
```

0 commit comments

Comments
 (0)