Skip to content

Commit

Permalink
Added support for DAX (#2248)
Browse files Browse the repository at this point in the history
This adds support for DAX (Data Analysis Expressions).
https://docs.microsoft.com/en-us/dax/
  • Loading branch information
peterbud authored Mar 13, 2020
1 parent 7d03ece commit 9227853
Show file tree
Hide file tree
Showing 16 changed files with 843 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@
"require": "clike",
"owner": "Golmote"
},
"dax": {
"title": "DAX",
"owner": "peterbud"
},
"diff": {
"title": "Diff",
"owner": "uranusjr"
Expand Down
27 changes: 27 additions & 0 deletions components/prism-dax.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions components/prism-dax.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions examples/prism-dax.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<h2>Comments</h2>
<pre><code>// This is a comment</code></pre>
<h2>Simple example</h2>
<pre><code>
Sales YTD :=
CALCULATE (
[Sales Amount],
DATESYTD( 'Date'[Date] )
)
</code></pre>
<h2>Full example</h2>
<pre><code>
Burn Rate (Hours) =

// Only consider those projects which have been alread created
VAR filterDate =
FILTER (
ALL ( 'Date'[Date] ),
'Date'[Date] &lt;= MAX('Date'[Date])
)

RETURN
IF (
// Show blank for months before project start
MAX ( 'Project'[Project Created Relative Months Pos] ) &lt; SELECTEDVALUE ( 'Date'[Fiscal RelativeMonthPos] ),
BLANK (),
MIN(
1,
DIVIDE (
// Add 0 to consider months with no hours
[Hours Actual Billable] + 0,
CALCULATE (
[Planned Hours] + 0,
filterDate
)
)
)
)
</code></pre>
1 change: 1 addition & 0 deletions plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"cmake": "CMake",
"csp": "Content-Security-Policy",
"css-extras": "CSS Extras",
"dax": "DAX",
"django": "Django/Jinja2",
"jinja2": "Django/Jinja2",
"dns-zone-file": "DNS zone file",
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions tests/languages/dax/boolean_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
TRUE
FALSE
NULL

----------------------------------------------------

[
["boolean", "TRUE"],
["boolean", "FALSE"],
["boolean", "NULL"]
]

----------------------------------------------------

Checks for booleans.
21 changes: 21 additions & 0 deletions tests/languages/dax/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**/
/* foo
bar */
//
// foo
--
-- foo
----------------------------------------------------

[
["comment", "/**/"],
["comment", "/* foo\r\nbar */"],
["comment", "//"],
["comment", "// foo"],
["comment", "--"],
["comment", "-- foo"]
]

----------------------------------------------------

Checks for comments.
29 changes: 29 additions & 0 deletions tests/languages/dax/datafield_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'table'[field]
'table name'[field]
'ta""ble'[field]
'ta''ble'[field]
'table'[field name]
'table name'[field name]
table[field]
table[field name]
'table'
'こんにちは'

----------------------------------------------------

[
["data-field", "'table'[field]"],
["data-field", "'table name'[field]"],
["data-field", "'ta\"\"ble'[field]"],
["data-field", "'ta''ble'[field]"],
["data-field", "'table'[field name]"],
["data-field", "'table name'[field name]"],
["data-field", "table[field]"],
["data-field", "table[field name]"],
["data-field", "'table'"],
["data-field", "'こんにちは'"]
]

----------------------------------------------------

Checks for datafield tokens.
Loading

0 comments on commit 9227853

Please sign in to comment.