You are on page 1of 52

Summary of DAX categories of functions

Introduction to DAX
When you create a Pivot Table report using PowerPivot, you are usually joining several tables together to
analyze the data in all the tables and generate results from all the information. When you link tables together
in Pivots, you create what is called a Data Model and when you are working in PowerPivot you are working
directly in this Data Model. Creating formulas in the Data Model, requires you to use a specialized language
and syntax. The language you use to create formulas in a Data Model Is DAX. A significant difference
between a DAX Function and an Excel function is that DAX Functions will always refer to a complete row,
column, or table. On the other hand, Excel Functions refer to a single cell or range of cells. This allows for
DAX Functions to return an entire table of results. In Pivots, you can use advanced formulas called
Measures. They can only be created after a PivotTable or PivotChart has been added to a workbook. They
will provide you with results dynamically and are dependent upon any filters that have been applied to the
PivotTable or PivotChart. For example, if you wanted to find the number of products that a single warehouse
has that are worth over $500, you could use a measure to find that information. Measures are often created
using DAX. Variables can also be used in a formula created with DAX which increases the flexibility of the
formula. By declaring a Variable first, the Variable name can be inserted in more complex expressions to
make them more readable. When a Variable is being defined, the definition begins with an equals sign
followed by “var”. The Variable name is then inserted followed by an expression. The syntax is as follows:
VAR <variable name> = <expression>. The results of the expression are stored as a Named Variable. Once
the Named Variable is declared, it can be used in many other expressions. While there are lots of DAX
Functions that you can choose from, each function will be classified under one of the following categories:

 Data and Time functions: Functions of this type are used to manipulate date and time values. As such, they
are like the data and time functions that can be used in Excel.
 Filter functions: These functions are used to manipulate data and filter it dynamically.
 Information functions: This type of function is used to scan the values inside a cell range and match them
against an expected data type.
 Logical functions: Typically, these functions are used to validate expressions and values, and then work with
other data that is based upon the evaluation.
 Math and Trigonometric functions: Functions of this type are used to perform mathematical calculations.
 Statistical functions: These functions are used to generate statistical data such as minimum and maximum
values, as well as averages.
 Time Intelligence functions: This type of function is used to manipulate data using time periods. It can be
used to compare data of one time-period against another.
Aggregate Functions are also more powerful in DAX. The standard Aggregate Functions in Excel can be used
in Excel spreadsheets, Pivot Tables, and PowerPivot Tables. DAX Aggregate Functions address many of the
shortcomings of standard functions by providing a means to aggregate data across columns and tables
instead of just cells and groups of cells. Below you will see the types of Aggregate Functions that are
available and what they do:

AVERAGE This function returns an average of all the numerical data in a column
AVERAGE This function returns an average of all the numerical data in a column, but it can also work with non-
A numerical data as well.
COUNT This function returns a count of the number of cells in a column that contain numerical data.
This function returns a count of the number of cells in a column that contain any data (numerical or
COUNTA
otherwise).
MIN This function returns the smallest number value that was found in a column.
MINX Returns the smallest value from a set of expressions evaluated over a table.
MAX This function returns the largest number value that was found in a column.
MAXX Returns the largest value from a set of expressions evaluated over a table.
SUM This function will add and display the total of all numbers in a column.
In addition to these functions, there are additional functions that are available in the DAX language only.
These functions include the following. AVERAGEX Averages a set of expressions evaluated over a table.
COUNTAX Counts a set of expressions evaluated over a table. COUNTX Counts the total number of rows in
a table. COUNTROWS Counts the number of rows returned from a nested table function, such as filter
function. SUMX Returns the sum of a set of expressions evaluated over a table.

Click on the link below to open the Microsoft Excel exercise document you can use to complete this
exercise.

Exercise: Creating PivotTables

2. Use your cursor to select cells A4:E40:


PIVOT TABLES EXERCISE

3. Next, click Insert → PivotTable:

4. The Create PivotTable dialog box is now displayed. The data range that you previously selected is
shown within the Table/Range text box:
5. You want this new PivotTable to be inserted into the current worksheet, so click the Existing
Worksheet radio button:
6. Inside the Location text box, click the range picker button:

7. Use your cursor to select cell H4:


8. Press Enter to apply the new location. Back at the Create PivotTable dialog box, click OK to apply
the new settings:

9. The PivotTable is now added to the current worksheet in the location that you previously set:
10. In the Pivot Table Fields task pane, click the Last Name, Daily Sales and Bonus field checkboxes:

11. You will see that the daily sales and bonuses have been summarized by Sales Representative:

12. To improve the number formatting, click the Sum of Daily Sales drop-down arrow in the Values
area and select Value Field Settings:
13. Now click Number Format:

14. In the Format Cells dialog box, click Currency, then click OK:
15. Click OK in the Value Field Settings dialog box:
16. Repeat the steps for the Bonus column. Once complete, the daily sales and bonus values should be
formatted correctly:

17. Save the current workbook as Activity 5-1 Complete and then close Microsoft 365 Excel to
complete this exercise.

18. Now, you can check out an example of a completed document in the link below:

SLICER EXERCISE
2. Click inside the PivotTable to display the PivotTable Tools contextual tabs. Next, click PivotTable
Analyze → Insert Slicer:

3. The Insert Slicer dialog box is now displayed:


4. Check the Last Name checkbox and then click OK:

5. A slicer for the Last Name field now appears on your worksheet:
6. For this exercise you want to filter out everyone except for Jerry Harrison and Leah Thompson. While
holding down the Ctrl key, click the Bressan, Prestwick, and Williamson buttons:

7. The entries that you clicked on in the slicer are now filtered out of the PivotTable:
8. Save the current workbook as Activity 5-2 Complete and then close Microsoft 365 Excel to complete
this exercise.

Customizing proofing and save options


1. To begin, open a blank workbook in Microsoft 365 Excel:
2. In the newly opened workbook, click cell B2 and type “MISSPEL”, then press Enter:

3. Now click Review → Spelling:

4. You should see an alert dialog box indicating the Spell check is complete with no suggested changes.
Click OK:

5. Next, click File → Options:


6. The Excel Options dialog box will open to the General category:
7. Click the Proofing category:
8. For this example, uncheck the “Ignore Words in UPPERCASE” checkbox as you want the spell checker to
examine words in this format:

9. Next, click the Save category:


10. Within the “Save workbooks” section, change the “Save AutoRecover information every” value in the
increment box from 10 to 8 minutes:

11. Click OK to apply the new changes:

12. Now check spelling again by clicking Review → Spelling:


13. Excel now suggests corrections to the text in cell B2. Click Change to accept the suggestion:

14. Click OK to acknowledge that the Spell check is complete:

15. You can now close Microsoft 365 Excel to complete this activity.

Exercise: Customizing workbooks


Note: You can pass this course and all graded assessments without access to the downloadable version of
Excel.
How to complete this exercise

To complete this exercise, you will need access to Microsoft 365 Excel.

Note: Keep in mind that if you are using free Office for the web or another version of the Microsoft 365 Excel
application some features covered in this exercise may not be available.

Free Office for the web

If you do not have access to Microsoft 365 Excel, you can use Free Office for the web. This version of Office
allows you to view and edit files in apps like Word, Excel, and PowerPoint. This free service is available to
anyone with a Microsoft account.

Access Microsoft Account

Log in to your Microsoft account. Type the email, phone number, or Skype sign-in that you use for other
services (Outlook, Office, etc.), then select Next. If you don't have a Microsoft account, you can select No
account? Create one!

Let's get started!

Note: You will need both these files to complete this activity:

 Exercise: Customizing workbooks


 Exercise: Customizing workbooks_image
Your supervisor has sent you a workbook with notes indicating his requests.

1. Click on the link below to open the Microsoft Excel exercise document you can use to complete this
exercise.

Exercise_Customizing workbooks

2. First, you would like to view all the notes on the worksheet. Click Review → Notes → Show All Notes:
3. There are two notes from John Smith. The first, in cell A2, asks you to add a background to the
worksheet:
4. Click Page Layout → Background:

5. The Insert Pictures dialog box opens. Click From a file:


6. Browse to your exercise folder and select Exercise_Customizing workbooks_image.png, then click Insert:

Note: In this activity we used Activity 7-1 as an example as seen below.


7. The background picture is added to the worksheet:
8. The second note asks how much it would cost to lower the daily sales goal to $2,000:
9. First note that the total of bonuses in cell I10 are $1,350. Now click cell I2 and type “2000” to change the
daily goals value, then press Enter:
10. The calculated total bonuses in cell I10 is now $1,500. It would cost $150 to lower the daily sales goal.
Press Ctrl + Z to undo the change made to cell I2, then click Review → Notes → Convert to Comments so
you can add your comments to the notes:

11. In the Excel alert dialog box, click Convert all notes:

12. Now click Review → Show Comments:

13. In the Comments task pane, in the first comment, in the reply text box, type “Done”, then click Post:
14. In the second comment type “An extra $150.” Again, click Post:
15. Close the Comment task pane, then hover your cursor over cell I2. Note that only your comment has a
date and time, as the previous comment was converted from a note:
16. Save the current workbook as Activity 7-1 Complete and then close Microsoft 365 Excel to complete this
exercise.

17. Now, you can check out an example of a completed document in the link below:

Exercise: Managing workbook properties


1. Click on the link below to open the Microsoft Excel exercise document you can use to complete this
exercise.

Exercise: Managing Workbook Properties

2. Hover your mouse over cell I19 and note the comment:

3. To open the Properties dialog box, click on File → Info → Properties → Advanced Properties:
4. The Properties dialog box will be opened. Click to select the Summary tab:

5. Type “Sales Commissions and Bonuses – January 2019” inside the Title field:
6. Type your name in the Author field:

7. Type “Acme Widgets” in the Company field:


8. Inside the Category field, type “Commissions:”

9. Click OK to update the properties:


10. You will now see the updated properties on the right side of the Info category:
11. Now click on Check for Issues → Inspect Document:
12. Click Yes to save the document:

13. Click Inspect to start the inspection:


14. Once complete you will note that there were comments found:
15. There were also document properties found, but you want to keep them. Click the Remove All button in
the comments field to remove the comments:

16. You can now click Close to return to the workbook:


17. Note that the comment in cell I19 has been removed:
18. Save the current workbook as Activity 2-1 Complete and then close Microsoft Excel 365 to complete the
activity.

17. Now, you can check out an example of a completed document in the link below:

Completed exercise: Managing Workbook Properties

Exercise: Using data sources


Note: You can pass this course and all graded assessments without access to the downloadable version of
Excel.

How to complete this exercise

To complete this exercise, you will need access to Microsoft 365 Excel.

Note: Keep in mind that if you are using free Office for the web or another version of the Microsoft 365 Excel
application some features covered in this exercise may not be available.

Free Office for the web


If you do not have access to Microsoft 365 Excel, you can use Free Office for the web. This version of Office
allows you to view and edit files in apps like Word, Excel, and PowerPoint. This free service is available to
anyone with a Microsoft account.

Access Microsoft Account

Log in to your Microsoft account. Type the email, phone number, or Skype sign-in that you use for other
services (Outlook, Office, etc.), then select Next. If you don't have a Microsoft account, you can select No
account? Create one!

Let's get started!

You have been asked to create a price list, in Canadian dollars, for some of your company’s products. You
will need to update it regularly using the current exchange rate. You first need to import your price list, then
create a web query to load and maintain the current exchange rate.

Note: The will need the following activities to complete this exercise:

 Exercise: Using Data Sources


 Exercise: Using Data Sources_text
1. Click on the link below to open the Microsoft Excel exercise document you can use to complete this
exercise.

Exercise: Using Data Sources

2. Click Data → From Text/CSV:

3. The Import Data dialog box will open. Navigate to your activity files and select Exercise: Using Data
Sources_text, then click the Import button:
4. The Get & Transform Data dialog box will open, displaying the data in the source file. If the selection in
the Delimiter drop-down list reads --Custom--, and there is an extra header, click to select the Tab option in
the Delimiter drop-down list:
5. With your data properly aligned in the list box, click the Load button:

6. A new worksheet is created and the data from your text file is loaded as a table. The Queries &
Connections task pane opens on the right of the screen:
7. Click on the Sheet1 tab to make it the active worksheet. Click to select cell A1, then press Ctrl + C to copy
the URL of the exchange rate site:
8. Now click Data → From Web:

9. The From Web dialog box will open. Click to select the URL field, then press Ctrl + V, to paste the URL.
Click OK:
10. The Navigator dialog box will open. Click to select Table 0 in the list box on the left, confirm the data is
present in the Table View window on the right, then click the Load button:

11. A new worksheet is created and the data from the website is loaded as a table. The query appears
under the Exercise: Using Data Sources
12. Hover your cursor over the web query in the Queries & Connections task pane, then click Edit in the
table dialog box that appears:
13. The Power Query Editor will launch. Click the filter button to the right of the header of the Country-
Currency column, then click to select the Text Filters field and begin typing “Canada”. When Canada-Dollar
is the only selected item, click OK:
14. Click the Close and Load command in the Close group of the Home tab:

15. You will see that the Web Query table now only displays the Canada-Dollar row of data from the data
set:
16. Click the Sheet2 tab to make it the active sheet, then click to select cell C2. Type the formula “=[@[US
Dollars]]*VLOOKUP("Canada-Dollar",Sheet3!A:B,2,FALSE)”, then press the Enter key:
17. The table containing the price list will auto complete the formula for every row in the column:

18. To refresh the data from the website, right-click on the query in the Queries and Connections task pane,
then select Refresh:
19. You can now save your changes as Activity 6-2 Complete and close Microsoft Excel 365 to complete the
activity.

20. Now, you can check out an example of a completed document in the link below:

You might also like