{"id":3971,"date":"2021-09-26T14:34:47","date_gmt":"2021-09-26T12:34:47","guid":{"rendered":"https:\/\/thebipower.fr\/?page_id=3971"},"modified":"2021-10-23T12:45:56","modified_gmt":"2021-10-23T10:45:56","slug":"dax-generator-documentation","status":"publish","type":"page","link":"https:\/\/thebipower.fr\/index.php\/dax-generator-documentation\/","title":{"rendered":"DAX generator native templates documentation"},"content":{"rendered":"\n<p class=\"has-text-align-center\"><strong>Warning : this documentation may mention some features under development which will appear in short term.<\/strong><\/p>\n\n\n\n<p>DAX templates are created by experts to be used by non experts and also by experts saving a lot of time. They can be documented to let the user know how to implement the DAX expression and which next steps to achieve. Templates can be easily used by newbies with the integrated wizard. <\/p>\n\n\n\n<p>DAX generator uses these templates to generate DAX expressions which might be measures, calculated columns, calculated tables, calculation groups, KPIs, translations and more.<\/p>\n\n\n\n<p>Templates can be stored in different locations :<\/p>\n\n\n\n<ol><li>In a DAX expression so the template is saved within a model<\/li><li>In a .qdt file stored locally or on the network<\/li><li>In a .qdt.json file stored in a GitHub repository<\/li><\/ol>\n\n\n\n<p>This documentation concerns only cases 1 and 2<\/p>\n\n\n\n<p>DAX generator keywords are always uppercase. Blue strings can be modified freely by templates authors. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Standard templates<\/h2>\n\n\n\n<p>A template starts with a DAX expression including the expression name.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span class=\"has-inline-color has-theme-palette-1-color\"><strong><em>YourQuickMeasure = COUNTROWS( 'YourTable' )<\/em><\/strong><\/span><\/code><\/pre>\n\n\n\n<p>As the user will be able to modify some elements (here the measure name and the table name), the best practice is to make these elements unique and descriptive. Ex : &#8216;_YourCalendarTable&#8217;.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Template information<\/h3>\n\n\n\n<p> &#8216;\/\/DG_DEFINITION:&#8217; starts template&#8217;s definition. This line and next ones will not appear in the generated DAX expression.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/DG_DEFINITION: <strong><em><kbd><span class=\"has-inline-color has-theme-palette-1-color\">==================================================================================<\/span><\/kbd><\/em><\/strong>\n\/\/DG_DESCRIPTION:<em><strong><span class=\"has-inline-color has-theme-palette-1-color\">Template description<\/span><\/strong><\/em>\n\/\/DG_AUTHOR:<em><strong><span class=\"has-inline-color has-theme-palette-1-color\">Author's name<\/span><\/strong><\/em>\n\/\/DG_WEBSITE:<strong><em><span class=\"has-inline-color has-theme-palette-1-color\">Related blog post URL or author's website<\/span><\/em><\/strong><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">DAX expression kind and name <\/h3>\n\n\n\n<p>The kind of the generated expression can be MEASURE, COLUMN,&nbsp;TABLE. More kinds will be added in the future.&nbsp;&nbsp;<br>It is followed by the expression name which must be exactly the same than in the DAX expression beginning the template. <br>Then comes a description used in tool tips and in the wizard.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/DG_OBJECT:MEASURE:<span class=\"has-inline-color has-theme-palette-1-color\"><strong><em>VourQuickMeasure<\/em><\/strong><\/span>:<span class=\"has-inline-color has-theme-palette-1-color\"><strong><em>Name of the measure DAX generator will create<\/em><\/strong><\/span><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Parameters<\/h3>\n\n\n\n<p>Authors may create as many parameters as they want. <br>Parameters kinds are TABLE&nbsp;,&nbsp;TABLE&amp;COLUMN&nbsp;,&nbsp;COLUMN&nbsp;,&nbsp;MEASURE&nbsp;,&nbsp;ANY.  More kinds will be added in the future. <br>It is followed by the parameter name which must be exactly the same than in the DAX expression beginning the template. <br>Then comes a description used in tool tips and in the wizard. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/DG_PARAMETER#1:TABLE:<span class=\"has-inline-color has-theme-palette-1-color\"><strong><em>YourTable<\/em><\/strong><\/span>:<span class=\"has-inline-color has-theme-palette-1-color\"><strong><em>Table we want to count rows (click to modify)<\/em><\/strong><\/span><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Instructions for end users<\/h3>\n\n\n\n<p>Instructions are shown in DAX generator screen and in the wizard. It is the best place to describe the template and steps to achieve. It might be followed by next steps after the DAX expression generation, best practices, &#8230;<br>Authors are free to refer to their website, social media, trainings, &#8230;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/DG_INSTRUCTIONS:<strong><em><span class=\"has-inline-color has-theme-palette-1-color\">Type your instructions here<\/span><\/em><\/strong>\n\/\/DG_INSTRUCTIONS:<strong><em><span class=\"has-inline-color has-theme-palette-1-color\">   Add more lines for more instructions<\/span><\/em><\/strong><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Advanced templates<\/h2>\n\n\n\n<p>Advanced templates use different methods than the standard ones. They involve different workflows and some dedicated pieces of code within DAX generator. They are not so flexible than standard templates but they are much mode powerful. For example, they can iterate through all columns in a model and generate a DAX measure depending on some conditions. They can also iterate through variables within a DAX expression or through visuals within a Pbix report. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Template method<\/h3>\n\n\n\n<p>A method defines the behavior of DAX generator against a template. By default, the standard method is applied. As a method requests some specific development, it is dedicated to a specific task. In order to create a new method, please contact us in GitHub discussions or through the contact form. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/DG_METHOD:METHOD_NAME<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Include a DAX expression<\/h3>\n\n\n\n<p>Instead of typing a DAX expression within the template, authors can ask the user to select an expression from their model.<br>Expressions kinds are : MEASURE, CALCULATED_TABLE, CALCULATED_COLUMN<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/DG_INCLUDE_BODY:MEASURE:<span class=\"has-inline-color has-theme-palette-1-color\"><strong><em>YourMeasureName<\/em><\/strong><\/span>:<strong><em><span class=\"has-inline-color has-theme-palette-1-color\">Name of the measure you want to use<\/span><\/em><\/strong><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Blocks<\/h3>\n\n\n\n<p>Blocks are pieces of code used in complex methods. Their use is defined by the method. For example, it can be a DAX expression for a calculation item.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/DG_BLOCK#1:CALCULATION_ITEM:<strong><em><span class=\"has-inline-color has-theme-palette-1-color\">Here is the DAX expression for a calculation item<\/span><\/em><\/strong>\n<span class=\"has-inline-color has-theme-palette-1-color\"><strong><em>YTD =\n    CALCULATE (\n        SELECTEDMEASURE (),\n        DATESYTD ( 'Date'&#91;Date] )\n    )<\/em><\/strong><\/span><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Different ways to create a template<\/h2>\n\n\n\n<p>My best .qdt template editor is VS Code but you may use any other text editor. In VS Code, I recommend you install one of the DAX extensions. Then, you can click on &#8216;Plain Text&#8217; in the right bottom corner and click on &#8216;Configure file association&#8217;. Select &#8216;DAX&#8217; (sometimes you will find it at the bottom of the list).<\/p>\n\n\n\n<ol><li>Click on the + button in the menu and select &#8216;Add template from model&#8217; then select a DAX expression. An simple template file is created. It is initialised with some instructions and a minimal template. Select the new template and click on &#8216;Open template in VS Code&#8217; menu. <\/li><li>Open a featured template and click on &#8216;Copy to user templates folder&#8217;<\/li><li>Create a template from scratch or get it from an other user<ul><li>The file location must be &#8216;C:\\Users\\<em>YourUsername<\/em>\\Documents\\Power BI Sidetools\\DAX generator templates\\User templates\\<em>YourSubfolder<\/em>&#8216;. <\/li><li>The extension must be .qdt<\/li><\/ul><\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Warning : this documentation may mention some features under development which will appear in short term. DAX templates are created by experts to be used by non experts and also by experts saving a lot of time. They can be documented to let the user know how to implement the DAX expression and which next&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"om_disable_all_campaigns":false,"_uag_custom_page_level_css":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false},"uagb_author_info":{"display_name":"Didier TERRIEN","author_link":"https:\/\/thebipower.fr\/index.php\/author\/masterpower\/"},"uagb_comment_info":0,"uagb_excerpt":"Warning : this documentation may mention some features under development which will appear in short term. DAX templates are created by experts to be used by non experts and also by experts saving a lot of time. They can be documented to let the user know how to implement the DAX expression and which next...","_links":{"self":[{"href":"https:\/\/thebipower.fr\/index.php\/wp-json\/wp\/v2\/pages\/3971"}],"collection":[{"href":"https:\/\/thebipower.fr\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/thebipower.fr\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/thebipower.fr\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thebipower.fr\/index.php\/wp-json\/wp\/v2\/comments?post=3971"}],"version-history":[{"count":15,"href":"https:\/\/thebipower.fr\/index.php\/wp-json\/wp\/v2\/pages\/3971\/revisions"}],"predecessor-version":[{"id":4070,"href":"https:\/\/thebipower.fr\/index.php\/wp-json\/wp\/v2\/pages\/3971\/revisions\/4070"}],"wp:attachment":[{"href":"https:\/\/thebipower.fr\/index.php\/wp-json\/wp\/v2\/media?parent=3971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}