An (Advanced) Introduction to DAX

Slides:



Advertisements
Similar presentations
By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and, in effect, increases the mental.
Advertisements

Mary K. Olson PS Reporting Instance – Query Tool 101.
Presenter: Dave Bennett
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Access 2007 ® Use Databases How can Access help you to find and use information?
State of Connecticut Core-CT Project Query 4 hrs Updated 1/21/2011.
 Agenda 2/20/13 o Review quiz, answer questions o Review database design exercises from 2/13 o Create relationships through “Lookup tables” o Discuss.
1.1 CAS CS 460/660 Introduction to Database Systems Relational Algebra.
Indexes and Views Unit 7.
Highline Class, BI 348 Basic Business Analytics using Excel Introduction to PowerPivot 1.
Access Queries Agenda 6/16/14 Review Access Project Part 1, answer questions Discuss queries: Turning data stored in a database into information for decision.
SQL Server Analysis Services 2012 BI Semantic Model BISM.
Module 4: Grouping and Summarizing Data. Overview Listing the TOP n Values Using Aggregate Functions GROUP BY Fundamentals Generating Aggregate Values.
Sorting data and Other selection Techniques Ordering data results Allows us to view our data in a more meaningful way. Rather than just a list of raw.
 Review quiz. Answer questions.  Discuss queries: ◦ What is a query? Turning data stored in a database into information for decision making. ◦ You: Completed.
BISM Introduction Marco Russo
Eugene Meidinger Execution Plans
Create Stored Procedures and Functions Database Management Fundamentals LESSON 2.4.
about me – Austin Senseman, CFA 5 years in Financial Services, Managed analytics for sales, marketing, risk, finance, &
Eugene Meidinger Power BI: Start to
Eugene Meidinger Intermediate Querying: Going Beyond Select
Extending and Creating Dynamics AX OLAP Cubes
Power BI: Getting Started and Keeping Up
Microsoft PowerBI – Advanced Solutions with Microsoft Excel and PowerBI Presented by: Phillip Guglielmi, CPA | Senior BI Consultant and Solutions Architect.
John Tran Business Program Manager, The Suddath Companies
Just Enough Database Theory for Power Pivot / Power BI
Power BI Internals Eugene
Building Tabular Models
An (Advanced) Introduction to DAX
45 Minutes to Your First Tabular Model
Unary Query Processing Operators
Keeping up With Technology: Drinking From the Firehose
Frontline Analytics | Brett Powell
Information Systems and Databases
Chelsea Dohemann Class will start at approximately 8:10am PowerPivot Chelsea Dohemann
Department of Computer Science,
Cross UG Summit EMEA /6/2018 7:24 PM
Your friends / colleagues can watch this session Live on !
Chapter 4 Relational Databases
CS 440 Database Management Systems
Relational Algebra Chapter 4, Part A
Power BI Performance …Tips and Techniques.
Introduction to tabular models
The 20% of DAX that Gets You 80% of the Way There
Introduction to tabular models
The Key to the Database Engine
Enriching your BI Semantic Models with Data Analysis Expressions (DAX)
Dynamic Programming.
WELCOME Howzit Sawubona.
Query Optimization Techniques
Relational Algebra Chapter 4, Sections 4.1 – 4.2
Evaluation Context Concepts and Examples.
Aggregations Various Aggregation Functions GROUP BY HAVING.
Modeling scenarios for DAX
Processing Analysis Services Tabular Models
The Relational Algebra
Power BI Part 1: A Business User’s Perspective
Power BI Part 2: Internals
Introduction to DAX Mike Davis, Consultant Architect.
Introducing DAX July 11th, 2015.
Execution plans Eugene
Power BI: Start to Finish
Query Optimization Techniques
Role Playing Dimensions in Tabular Data Models
LINQ to SQL Part 3.
Annoyed with a stubborn pivot table? PowerPivot is your answer.
Dax for most data professionals
Login Main Functions Via SAS Information Delivery Portal
Presentation transcript:

An (Advanced) Introduction to DAX Eugene Meidinger @sqlgene www.sqlgene.com/powerbi/ emeidinger@all-lines-tech.com

About me Business Intelligence developer Worked for All-Lines for 5 years Spoken at Pittsburgh SQL User Group and various SQL Saturdays Help lead the Pittsburgh Power BI User Group Pluralsight Author Went from SQL newb to SQL pro

What is the goal of this talk? Focus on core concepts Building the basic mental model What is difficult to understand?

Overview Calculated columns vs measures Columnar storage Aggregations Filtering Filter contexts Iterators

DAX is NOT X DAX is not Excel DAX is not SQL DAX is not MDX DAX is painful if you don’t get this The concepts are harder than the syntax

There are two types of business logic Calculated columns Measures

Calculated columns Represents a single value per row Computed at time of creation/refresh Results are materialized and stored with the table Attached to a specific table Normally can only see the row they exist in Relates to the idea of row context More on this later Can be used in filters or values/results areas

Example Calculated Column GrossMargin = Sales[Price] – Sales[Cost]

Measures Represents a single value per data model Computed at run time Results are dynamic, based on filters This is called the filter context Not attached to any table Sees all the data at once

Example Measure TotalQuantity := SUM(Sales[Quantity])

Implicit measures If you use a calculated column as a value/result it creates an implicit measure

DAX is good at two things Aggregations Filtering

What is an aggregation? Aggregation is combining a group of values into one value Examples SUM AVERAGE MIN MAX DISTINCTCOUNT

Quantity 4 1 3 2 7 5 SUM(Quantity) 23

DAX stores data as columns Super efficient for simple aggregations Many aggregate functions take columns as parameters DAX is optimized for single-column operations Columns are the fundamental unit of measure

Basic units of measure Column Table Scalar Value Row A set of columns with the same length and sort order Scalar Value Row A table filtered down to a single row Also called a row context

Compression and encoding Value Encoding Dictionary Encoding Run-length encoding Sorting

Color Blue Green Red Color Blue,1 Green,2 Red, 4

DAX is good at two things Aggregations Filtering

Two types of Filtering Implicit filtering Explicit filtering

Implicit Filtering Slicers Cell Location

Explicit Filtering GreenQuantity := CALCULATE(SUM(Sales[Quantity]), Sales[Color]="Green") Explicit filtering supersedes implicit filtering

Filtering Context A combination of all the user filters Basic filters are associated with specific, individual columns CALCULATE allows you to overwrite the filter context

Removing Filtering The ALL() function removes filters Can be used on a whole table, or specific columns AllColors:=CALCULATE(SUM(Sales[Quantity]), ALL(Sales[Color]))

Applying complex filtering This causes an error: CALCULATE(SUM(Sales[Quantity]), Sales[Price] - Sales[Cost] <= 1) Need to use something called an “iterator” FILTER() takes in a table and an expression Returns a filtered table

Example FILTER() LowMargin:=CALCULATE(SUM(Sales[Quantity]),FILTER(Sales, Sales[Price] - Sales[Cost] <= 1))

Iterators Process tables row by agonizing row Expensive to process Rows are filtered one at a time. Called a row context Often a filter context AND a row context is applied Necessary to refer to multiple fields in the same row SUM(Sales[Price] - Sales[Cost]) raises an error

Example Iterator AverageGrossMargin1:=AVERAGE(Sales[GrossMargin]) AverageGrossMargin2:=AVERAGEX(Sales, Sales[Price] - Sales[Cost]) Requires a table parameter to “iterate” through Iterators are expensive

Key concepts Calculated columns are materialized values in a table Measures look at all the data plus the filter context Explicit filtering overrides implicit filtering DAX is optimized for single-column operations Rows don’t exist, but row contexts do Multi-column operations require iterators, which are expensive CALCULATE() + FILTER() / ALL() can be used to apply advanced filtering

Book Recommendations

Questions? Contact Info @sqlgene www.sqlgene.com/powerbi/ emeidinger@all-lines-tech.com