Download presentation
Presentation is loading. Please wait.
1
Cross UG Summit EMEA 2017 8/6/2018 7:24 PM
© 2017 Dynamic Communities. All rights reserved.
2
DAX 101 for Power BI Belinda Allen Microsoft MVP
8/6/2018 7:24 PM DAX 101 for Power BI Belinda Allen Microsoft MVP Business Intelligence Program Manager
3
Back of my Surface Book
4
Me… Business Intelligence Program Manager (aka BA Nut) – PowerGP Njevity, Inc. Microsoft MVP – Business Solutions GPUG All-Star Advisor – Association of Dynamics Professionals Credentialing Council Board of Advisors for PBIUG Author: 2 books Belinda Allen
5
Single Function Code Data Analysis eXpressions
What is DAX? Data Analysis eXpressions Functional Language used by Microsoft Power BI, PowerPivot And SSAS Tabular Single Function Code
6
DAX Excel MDX TSQL
7
Aggregate - Defined
8
Iterate - Defined
9
M Language Simple Math Text Fields Everything Else
10
What can be created with DAX?
Calculated Columns Calculated at refresh time, result stored in data Calculates using the current row, not a specific row Calculated Measures Great for values that we do not want to be performed on a row by row basis or have them aggregated. Code stored with data, calculated with visual
11
Syntax Notes: Total Sale = ‘Sales’[Quantity] * ‘Sales’[Unit Price] Table name in single quotes (if spaces or characters exist) Column name in square brackets *Always use the table name with the field! It makes it easier to read later.
12
Data Type Handling (Operator Overloading)
Operators are NOT strongly typed The result depends on the inputs Operator Overloading kills speed Know your data type Adding 2 strings “5” + “4” = 9 Concatenate 2 strings 5 & 4 = “54”
13
Calculated Columns and Measures Demo
14
Column syntax vs. Measure syntax
Gross Margin Percent = ‘Sales’[Gross Margin] / ‘Sales’[Sales Amount] Measure: Gross Margin Percent Measure = SUM(‘Sales’[Gross Margin]) / SUM(‘Sales’[Sales Amount]) Creates Gross Margin For each Row Creates Gross Margin For Totals
15
When to use Column or Measure
Need to slice or filter on value Calculate percentages or ratios Need complex aggregations Consumes Memory Consumes CPU
16
Demo – Calculated Column
Dynamics GP Tech Conference 8/6/2018 7:24 PM Demo – Calculated Column
17
Add Column Demo Current Row Single Quote Query Name
18
Demo – Calculated Measure
Dynamics GP Tech Conference 8/6/2018 7:24 PM Demo – Calculated Measure
19
Calculated Columns vs. Measures
Need to slice value Need to filter value Consumes Memory / Space Measure Calculate %’s Calculate Ratios Consumes CPU Complex Aggregations
20
Dynamics GP Tech Conference
8/6/2018 7:24 PM Aggregate Functions SUM MIN MAX AVERAGE Aggregate Functions with Iterations SUMX MINX MAXX AVERAGEX
21
Count Functions COUNT (only for numeric columns) COUNTA (counts all rows EXCEPT blanks) COUNTBLANK (counts only blanks) COUNTROWS (counts rows in table) DISTINCTCOUNT (counts unique fields)
22
AND (&&)* OR (||)* NOT (!)* IF IFERROR Booleon Logical Functions
*Can use C# Operators
23
Information Functions
ISBLANK ISNUMBER ISTEXT ISNONTEXT ISERROR
24
MAX and MIN Functions to compare values
Computes the maximum of Extended Price = MAX('Sales Line Items'[Extended Price]) Measure Column Computes the maximum between Gross Margin and Cost =MAX('Sales’[Extended Cost], 'Sales'[Gross Margin])
25
DIVIDE Function IF ( Sales[Sales Amount] <> 0,
Sales[Gross Margin] / Sales[Sales Amount], 0) DIVIDE ( Sales[Gross Margin], Sales[Sales Amount],
26
Math, Text & Date Functions
Many similar Excel functions
27
Using fields from different Queries - Demo
28
Related Functions RELATED RELATEDTABLE
Uses the Many side to grab a row from the one side in a Many to One relationship. Commission = ‘Sales’[SalesAmount] * RELATED(‘Salesperson’[CommRate]) RELATEDTABLE Uses the One side to grab an aggregate from the many side in a One to Many relationship NumberOfSales = COUNTROWS(RELATEDTABLE(‘Sales’)) Sales = SUMX(RELATEDTABLE(‘Sales’), ‘Sales’[Quantity] * ‘Sales’[UnitPrice])
29
Tables Functions FILTER ALL VALUES DISTINCT RELATEDTABLE
30
Declaring and using Variables
Corrected Quantity:= VAR TotalQuantity = SUM(Sales[Quantity]) RETURN ( IF ( TotalQuantity > 1000, TotalQuantity * .95, TotalQuantity * 1.25 )
31
Q&A Ballen@Njevity.com
Dynamics GP Tech Conference 8/6/2018 7:24 PM Q&A
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.