Example Materials Power BI Desktop File (4/16): https://drive.google.com/file/d/0B4dDgyQg- 6WPbWY5UTRhaHYwdDA/view?usp=sharing.

Slides:



Advertisements
Similar presentations
Visualize Success 2011 Alan Chorney Professional Services Visual South, Inc. Troubleshooting Costing Visualize Success 2012.
Advertisements

Microsoft Office Illustrated Fundamentals Unit H: Using Complex Formulas, Functions, and Tables.
Concepts of Database Management Seventh Edition
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
Chapter 11 Group Functions
Tutorial 5: Working with Excel Tables, PivotTables, and PivotCharts
Tutorial 7: Using Advanced Functions and Conditional Formatting
Visualizing and Exploring Data Copyright © 2013 Pearson Education, Inc. publishing as Prentice Hall 3-1.
A Guide to SQL, Seventh Edition. Objectives Retrieve data from a database using SQL commands Use compound conditions Use computed columns Use the SQL.
Introduction Paul Turley SqlServerBiBlog.com Mentor, SQL Server MVP
DAX uses a syntax similar to Excel TableX [ColY] or [ColY] (fully qualified vs. not qualified) Cells cannot be referenced (like B23, B12:C15, …)
Tutorial 5: Working with Excel Tables, PivotTables, and PivotCharts
Implementing Common Business Calculations in DAX
Concepts of Database Management, Fifth Edition
Chapter 6 Group Functions. Chapter Objectives  Differentiate between single-row and multiple-row functions  Use the SUM and AVG functions for numeric.
Chapter 3 Single-Table Queries
Syntax MROUND(number,multiple) Number is the value to round. Multiple is the multiple to which you want to round number. Remark MROUND rounds up, away.
Term 2, 2011 Week 1. CONTENTS Types and purposes of graphic representations Spreadsheet software – Producing graphs from numerical data Mathematical functions.
PowerPivot Hope Foley Perpetual Technologies. Who Am I?  Microsoft Team Lead  SQL Server DBA  (MCITP: Database Administration in 2005 and 2008)  In.
Chapter 11 Creating Formulas that Count and Sum Microsoft Excel 2003.
Objects for Business Reporting MIS 497. Objective Learn about miscellaneous objects required for business reporting. Learn about miscellaneous objects.
CHAPTER 36 Averages and Range. Range and Averages RANGE RANGE = LARGEST VALUE – SMALLEST VALUE TYPES OF AVERAGE 1. The MOST COMMON value is the MODE.
Prescriptive Analytics Appendix A EXCEL TOOLS FOR THE MANAGEMENT SCIENTIST Business Analytics with Management Science Models and Methods Arben Asllani.
PIVOT TABLES AND CHARTS CS1100 Computer Science and its Applications CS1100Pivot tables and charts1.
DAY 9: EXCEL CHAPTER 6 Tazin Afrin September 17,
Reporting in Version 5 Application Reports AKA: In Context or Right Click AKA: In Context or Right Click Export to Excel from Listing pages Management.
1 Single Table Queries. 2 Objectives  SELECT, WHERE  AND / OR / NOT conditions  Computed columns  LIKE, IN, BETWEEN operators  ORDER BY, GROUP BY,
Concepts of Database Management Seventh Edition
Microsoft Office 2007 Intermediate© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! With Microsoft ® Office 2007 Intermediate Chapter.
An Internet of Things: People, Processes, and Products in the Spotfire Cloud Library Dr. Brand Niemann Director and Senior Data Scientist/Data Journalist.
ESD.70J Engineering Economy Module - Session 21 ESD.70J Engineering Economy Fall 2006 Session Two Alex Fadeev - Link for this PPT:
XP. Objectives Sort data and filter data Summarize an Excel table Insert subtotals into a range of data Outline buttons to show or hide details Create.
In this session, you will learn to: Use functions to customize the result set Summarize and group data Objectives.
1 Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall. by Mary Anne Poatsy, Keith Mulbery, Eric Cameron, Jason Davidson, Rebecca Lawson,
Organizing & Reporting Data: An Intro Statistical analysis works with data sets  A collection of data values on some variables recorded on a number cases.
Microsoft Excel 2013 Chapter 8 Working with Trendlines, PivotTable Reports, PivotChart Reports, and Slicers.
A Guide to SQL, Eighth Edition Chapter Four Single-Table Queries.
PIVOT TABLES AND CHARTS Leena Razzaq CS1100 Computer Science and its Applications CS1100Pivot tables and charts1.
1 Chapter 3 Single Table Queries. 2 Simple Queries Query - a question represented in a way that the DBMS can understand Basic format SELECT-FROM Optional.
Introduction to Excel Lecture 3. Excel basics O Excel is a software program that can make number manipulation easy O It is also referred as a spreadsheet.
Intro to Power BI Azhagappan Arunachalam.  Senior Database Architect   PowerBICentral.com  (blog on getting started.
Write DAX Queries using DAX Studio Alex Barbeau
about me – Austin Senseman, CFA 5 years in Financial Services, Managed analytics for sales, marketing, risk, finance, &
AGB 260: Agribusiness Information Technology Advanced Functions and Logic.
Retrieving Information Pertemuan 3 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
John Tran Business Program Manager, The Suddath Companies
MSAA PRESENTS: AN EXCEL TUTORIAL
Building Tabular Models
Office tool for creating tables and charts
Excel Functions.
Chelsea Dohemann Class will start at approximately 8:10am PowerPivot Chelsea Dohemann
Tutorial 5: Working with Excel Tables, PivotTables, and PivotCharts
Microsoft Office Illustrated
Cross UG Summit EMEA /6/2018 7:24 PM
Module 11: Introduction to DAX Module 11 Introduction to DAX
Budgeting with Power Pivot
QAD Browses.
WELCOME Howzit Sawubona.
SQL Saturday New York City May 19th, 2018
Modeling scenarios for DAX
Lesson 4: Introduction to Functions
Topic 8 – Pivot tables and Charts Lesson 1 – Pivot tables
Using Complex Formulas, Functions, and Tables
Lessons 3: Coffee Shop Inventory
Microsoft Office Illustrated Fundamentals
Introduction to Spreadsheets
Group Operations Part IV.
Presentation transcript:

Example Materials Power BI Desktop File (4/16): 6WPbWY5UTRhaHYwdDA/view?usp=sharing

Intro to DAX Patterns

Eric Bragas – MCP, PSM I DesignMind - Business Intelligence Consultant

Agenda DAX Data Analysis Expressions Notation Functions Evaluation Contexts Measure Patterns Calculated Column Patterns

Data Analysis Expressions (DAX) What is DAX? DAX is a language that allows us to write dynamic expressions for relataional constructs, using familiar functions Powerful dynamic data analysis tool for relational data Expressions can traverse relationships! Available in PowerPivot, PowerBI, and SSAS Tabular Classic “Import Mode” What isn’t DAX? NOT a programming language

DAX Notation Table ‘Table’ Column ‘Table’[Column] Function fn ( ) Measure Measure Name := SUM ( ‘Table’[Column] ) Calculated Column Column Name = SUM ( ‘Table’[Column] )

Measures A measure is a formula/expression comprising functions applied to columns and tables Reusable aggregation evaluated differently, depending on how you use it Measures can be nested

Functions Logical IF( logical test,, ) SWITCH(,,, … ) – evaluates an expression against a list of values, and returns the result corresponding to the first matching value TRUE() – returns logical true Aggregate SUM( ) – adds all the numbers in a column DIVIDE(,, [, ] ) – basic division; optional value returned Statistical MAX( ) – returns the largest numeric value in a MIN( ) – returns the smallest value in a Text BLANK() – returns a blank Filter FILTER(, ) – returns a table representing a subset of another table or expression ALL( | ) – returns all the rows in a table, ignoring any filter context VALUES( ) – returns one column of the distinct values from the specified column or table CALCULATE(,,, … ) – evaluates an expression in a context that is modified by the specified filters

Functions (cont’d) Date and Time TODAY() – returns the current date NOW() – returns the current date and time in datetime format Time Intelligence* DATESBETWEEN(,, ) – returns a table of starting with the and continues until the. NEXTDAY( ) – returns a table that contains a column with the next dates following each of the passed FIRSTDATE( ) – returns the first date in the context of the specified column of dates LASTDATE( ) – returns the last date in the context of the specified column of dates SAMEPERIODLASTYEAR( ) – returns a table with a column of dates shifted one year back for each of the specified LASTNONBLANK(, ) – returns last value in the where the returns blank FIRSTNONBLANK(, ) – returns the first value in the where the returns blank *Requires Date Table

Evaluation Contexts Evaluation Contexts: Filter Context Four types of filter context: 1.Row Selection 2.Column Selection 3.Slicer Selection 4.Filter Selection Defines the subset of data a measure is calculated using aka “Which rows are selected based on which attribute values?” Applied before anything else Row Context All the columns in the Current Row “DAX is simple, it’s not easy, but it’s simple” - Alberto Ferrari

Basic Evaluation Context - Demo TotalSales = SUM ( Sales[SalesAmount] )

Anatomy of a Filter Context - PivotTable Rows Columns Filter Slicer

Anatomy of a Filter Context - Chart Column Filter Slicer

Measure Patterns Basic Cumulative YTD Year Over Year Semi-additive Disconnected Slicers

Basic Measures SUM( ‘Sales’[SalesAmount] ) AVERAGE( ‘Inventory’[InventoryOnHand] ) MIN( ‘Weather’[Temp] ) MAX ( ‘Weather’[Temp] ) Etc.

Basic Measure Demo – PowerPivot & PowerBI Asia Sales := CALCULATE ( [Total Sales], Geography[ContinentName] = "Asia" ) Asia Sales := CALCULATE ( [Total Sales], FILTER ( 'Geography', Geography[ContinentName] = "Asia" ) ) Boolean Table

Cumulative Total Measures Aggregates values of a column for the currently selected date and all previous dates within the specified range Can be used to derive balances from transactions eg. Inventory Stock Balances Cumulative Balances Does not require use of Time Intelligence functions

Cumulative Measure Demo - PowerBI Cumulative Energy Generated (Checked) = IF ( MIN ( 'Date'[Date] ) <= MAX ( ‘Output’[Date], ALL ( ‘Output’ ) ), CALCULATE ( SUM ( 'Output'[Energy Generated] ), FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] <= MAX ( 'Date'[Date] ) ) )

Year-to-Date Total TOTALYTD function applies the expression for all data from the start of the year to the currently selected date in the filter context Year To Date = TOTALYTD(, [, ] [, ] )

Year-to-Date Total Demo - PowerBI Total Energy Generated YTD = TOTALYTD ( SUM ( 'Output'[Energy Generated] ), 'Date'[Date] )

Year Over Year Use time intelligence to calculate an aggregate for the same period last year “Last Year” measure is used to compare to “Current Year” measure, and/or to derive a measure of the change year-over-year

Year-Over-Year Demo – PowerBI Total Energy Generated Last Year = CALCULATE ( [Total Energy Generated], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )

Semi-Additive Measures Snapshot Fact Table with balance values, such as Inventory or Account Balances These scenarios disallow us from summing across time The solution is to sum across all attributes except for time by filtering for only a single point in time (eg. last date in the period) Several functions allow you to adjust filter context to a single point in time, within the original context period FIRSTDATE / LASTDATE FIRSTNONBLANK / LASTNONBLANK OPENING… / CLOSING…

Semi-Additive Measure Demo - PowerPivot Total On Hand Quantity LASTNONBLANK = CALCULATE ( SUM ( Inventory[OnHandQuantity] ), LASTNONBLANK ( 'Date'[Date], CALCULATE ( SUM ( Inventory[OnHandQuantity] ) ) ) )

Disconnected Slicers Allows you to use a slicer to modify measures Measure Switching Used to switch between a set of measure values in a container measure

Disconnected Slicers Demo - PowerBI Setup Steps: 1.Create/identify your target measures (eg. [Energy Exported] & [Energy Generated]) 2.Create disconnected table to use in slicer selection 3.Create background “value selection measure” using MAX() Hide this! 4.Create SWITCH measure to use in visualizations

Calculated Column Patterns Value Binning

Used to group similar values, or to bin values for analysis aka Histograms Can bin values based on equality, or inequality comparisons with the SWITCH() function Use Cases: Age groups Product Groups Any kind of frequency distributions

Value Binning Demo - PowerBI Inventory Age (bin) = SWITCH ( TRUE (), 'Inventory'[DaysInStock] < 20, "0-20", 'Inventory'[DaysInStock] < 50, "21-50", 'Inventory'[DaysInStock] < 80, "51-80", 'Inventory'[DaysInStock] < 100, "81-100", "101+" )

Summary DAX is dynamic because you can write measures that correctly evaluate under their current Evaluation Context Filter Context Row Context Functions are the building blocks of our measures and perform a myriad of tasks eg. altering Context, aggregating, logical operations, time intelligence, etc Time Intelligence functions require a Date table to operate Understanding Tabular Data Modeling will go a long way towards helping your understanding of DAX

Thanks!