Creating a calculated table

First, we will create a calculated table as follows:

  1. Click on the Modeling tab.
  2. Choose New Table from the Calculations section of the ribbon. The Formula bar will appear with the words Table =, and the cursor will become active within the Formula bar.
  3. Type the following formula into the Formula bar, replacing the existing text in its entirety:
 Calendar = CALENDAR( DATE(2017 ,1 ,1), DATE(2019 ,12 ,31) )

The preceding and subsequent formulas in this book are created and tested for the English language version of Windows and Power BI Desktop. Different language settings for Windows or Power BI may impact these formulas slightly. To make the formulas as compatible as possible, spaces have been added before commas preceded by numbers to account for cultures that use commas for decimal points. This may look a bit odd, but this is the most compatible approach with various cultures.

This formula creates a table named Calendar that has a single column called Date. This table and column will appear in the Fields pane. The CALENDAR function is a DAX function that takes as input a start and end date. We used another DAX function, DATE, to specify the start and end dates of our calendar. The DATE function takes a numeric year, month, and day value and returns a date/time data type representative of the numeric inputs provided.

Here is what your screen should look like:

Figure 2: The DAX formula bar

Congratulations! You have just written your first DAX formula!

  1. Press the Enter key on the keyboard to create a table called Calendar in your data model. Switch to the Data view in order to view the created table:

Figure 3: Calendar table

Note, at the bottom in the footer, that this table consists of 1,095 rows of data. In fact, this table contains a row for every date inclusive of, and between, January 1, 2017 and December 31, 2019. If you don't see this information in the footer, make sure to select the table in the Fields pane.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.238.159