DAX uses a syntax similar to Excel TableX [ColY] or [ColY] (fully qualified vs. not qualified) Cells cannot be referenced (like B23, B12:C15, …)

Slides:



Advertisements
Similar presentations
CS1100: Computer Science and Its Applications Building Flexible Models in Microsoft Excel.
Advertisements

8. Introduction to Spreadsheet CSCI N207 Data Analysis Using Spreadsheet Lingma Acheson Department of Computer and Information Science,
33 CHAPTER BASIC APPLICATION SOFTWARE. © 2005 The McGraw-Hill Companies, Inc. All Rights Reserved. 1-2 Announcement: QUIZ#02 In Lecture Session # 9 (5.
Chapter 11 Group Functions
Chapter 11 Group Functions (up to p.402)
Referencing Pivot Table Cells with GetPivotData Robert Rosen.
BASIC FUNCTIONS OF EXCEL. Addition The formula for addition is: =SUM( insert cells desired to sum up ) This returns the sum of the selected cells.
Tutorial 7: Using Advanced Functions and Conditional Formatting
Microsoft Excel 2003 Illustrated Complete Data with PivotTables Analyzing.
Introduction to Oracle9i: SQL1 SQL Group Functions.
Tutorial 8: Working with Advanced Functions
Implementing Common Business Calculations in DAX
Chapter 6 Group Functions. Chapter Objectives  Differentiate between single-row and multiple-row functions  Use the SUM and AVG functions for numeric.
With Microsoft Office 2007 Introductory© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Introductory.
Objects for Business Reporting MIS 497. Objective Learn about miscellaneous objects required for business reporting. Learn about miscellaneous objects.
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 4 BACKNEXTEND 4-1 LINKS TO OBJECTIVES Query Design Query Criteria Modify a Query Using OR.
Overview of User Set-up & Security. Template Overview  Unique Template & Mapping Technology  Off the shelf/customised Template containing lookups for.
Microsoft Excel 2007 © Wiley Publishing All Rights Reserved. The L Line The Express Line to Learning L Line.
1 Single Table Queries. 2 Objectives  SELECT, WHERE  AND / OR / NOT conditions  Computed columns  LIKE, IN, BETWEEN operators  ORDER BY, GROUP BY,
PowerPivot For Excel 2010PowerPivot For SharePoint 2010.
11 Chapter 2: Formulas and Functions Chapter 02 Lecture Notes (CSIT 104) Exploring Microsoft Office Excel 2007.
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.
SQL LANGUAGE and Relational Data Model TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
= IF ( FactResellerSales[DiscountedPrice]
Intermediate Excel 2013 Session II. Previously… By the end of this session you should be able to: Use the filter tool to only display data that meets.
Highline Class, BI 348 Basic Business Analytics using Excel Introduction to PowerPivot 1.
SQL Aggregation Oracle and ANSI Standard SQL Lecture 9.
PERFORMING CALCULATIONS Microsoft Excel. Excel Formulas A formula is a set of mathematical instructions that can be used in Excel to perform calculations.
- Professor Kurt Brandquist - IT133 Software Applications Unit 6 Seminar: Formulas and Functions Wednesday, 6/22/11.
Intermediate Excel 2013 Gareth Johns IT Skills Development Advisor.
Alyson Powell Erwin Sr. Program Manager Microsoft BIN307.
Example Materials Power BI Desktop File (4/16): 6WPbWY5UTRhaHYwdDA/view?usp=sharing.
about me – Austin Senseman, CFA 5 years in Financial Services, Managed analytics for sales, marketing, risk, finance, &
Level 200 Let‘s learn DAX Tomislav Piasevoli Piasevoli analitika d.o.o.
Retrieving Information Pertemuan 3 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
John Tran Business Program Manager, The Suddath Companies
Presenter Date | Location
Programming Patterns with BISM Tabular
Building Tabular Models
Using Advanced Functions and Conditional Formatting
An (Advanced) Introduction to DAX
Excel Functions.
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Chelsea Dohemann Class will start at approximately 8:10am PowerPivot Chelsea Dohemann
Tutorial 5: Working with Excel Tables, PivotTables, and PivotCharts
Getting Started in Power BI
Analyzing Table Data.
An (Advanced) Introduction to DAX
SUB-ICT STD-10 Working with Data in Microsoft Excel
Cross UG Summit EMEA /6/2018 7:24 PM
Module 11: Introduction to DAX Module 11 Introduction to DAX
Microsoft Access 2003 Illustrated Complete
Prof: Dr. Shu-Ching Chen TA: Yimin Yang
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
SQL LANGUAGE and Relational Data Model TUTORIAL
Evaluation Context Concepts and Examples.
Chapter 4 Summary Query.
Prof: Dr. Shu-Ching Chen TA: Haiman Tian
Modeling scenarios for DAX
Access: SQL Participation Project
Data Analysis Expressions in PowerPivot for Excel 2010
Contents Preface I Introduction Lesson Objectives I-2
Query Functions.
Introduction to DAX Mike Davis, Consultant Architect.
Section 4 - Sorting/Functions
Introducing DAX July 11th, 2015.
Introduction to SQL Server and the Structure Query Language
Group Operations Part IV.
DAX: Functions and Context That’s What It’s All About!
Presentation transcript:

DAX uses a syntax similar to Excel TableX [ColY] or [ColY] (fully qualified vs. not qualified) Cells cannot be referenced (like B23, B12:C15, …) DAX functions operate with table columns

Using DAX Calculated Columns

Using DAX Measures (or Calculated Field)

Sales Table [Amount] = [Qty] * [Price] [Unit Cost] = RELATED (Product [Cost]) [Total Cost] = [Qty] * [Unit Cost] [Margin] = [Amount] – [Total Cost] MarginPct = [Margin] / [Amount] Customer table [Sales] = SUMX (RELATEDTABLE(Sales), Sales[Amount])

Implicit Measures Automatically defined for all numeric columns Created measure “Sum of ” Can be changed to Avg, Count, Min, Max Explicit DAX Measures Gives a name to a DAX expression (formula) Can use complex expressions Interaction with Filter Context [Margin %] = SUM( [Margin] ) / SUM( [Amount] )

Row Context Similar to current row concept i.e. row of calculation for calculated column It gives a meaning to a column reference Evaluation of expression in aggregation function Filter Context Set of filters that defines “active” rows for each table Filters on single columns or on table rows Can be manipulated by using CALCULATE Every cell in a pivot table defines a filter context

RELATED( table[column] ) Follows relationship many-to-one Reads column value in the corresponding row of the related table RELATEDTABLE( table ) Follows relationship in both directions Returns a table containing corresponding rows in the related table Must be used as a parameter calling another function – i.e.: SUMX ( RELATEDTABLE(Sales), Sales[Amount])

Date and TimeInformationMath and TrigStatisticalText DATEISBLANKABSAVERAGECHAR DATEVALUEISERRORCEILING, ISO.CEILINGAVERAGEACODE DAYISLOGICALEXPCOUNTCONCATENATE EDATEISNONTEXTFACTCOUNTAEXACT EOMONTHISNUMBERFLOORCOUNTBLANKFIND HOURISTEXTINTMAXFIXED MINUTELNMAXALEFT MONTHLogicalLOGMINLEN NOWANDLOG10MINALOWER SECONDIFMODMID TIMEIFERRORMROUNDREPLACE TIMEVALUENOTPIREPT TODAYORPOWERRIGHT WEEKDAYFALSEQUOTIENTSEARCH WEEKNUMTRUERANDSUBSTITUTE YEARRANDBETWEENTRIM YEARFRACROUNDUPPER ROUNDDOWNVALUE ROUNDUP SIGN SQRT SUM SUMSQ TRUNC

Table Functions in DAX Differences between Excel and PowerPivot Excel doesn’t have functions returning a table Calculated Columns and Measures must return scalar values DAX includes functions returning a table Used as intermediate results passed as arg to other functions Often used for DAX aggregation functions (aggX) Differences from Excel

Table Functions in DAX Rows of related table following the relationship RELATEDTABLE (Table) Filter rows from Table according Condition (whenever that Boolean expression evaluates to true) FILTER (Table, Condition) Table made of a single column containing all the distinct (unique) values of a table column DISTINCT (Column) As DISTINCT, but also returns “unknown” (i.e. invalid relationships) VALUES (Column) Returns all data ignoring filter context and avoiding duplicates ALL (Table), ALL (Column) Returns rows from a table using filter context only for specified columns ALLEXCEPT (Table, Col1, Col2,..) Functions List

Functions that transform Filter Context CALCULATE ALL FILTER … Syntax samples Regular syntax (SalesAmt have to be an explicit measure) = [SalesAmt] / CALCULATE( [SalesAmt], ALL (Product) ) Shortened syntax =[SalesAmt] / [SalesAmt]( ALL(Product) )

Measures on Sales Table A measure can reference other explicit measures defined in DAX References to implicit measures require aggregation functions [Sales] = SUM ( Sales [Amount] ) [AllProd] = CALCULATE ([Sales], ALL(Product) ) = [Sales] ( ALL(Product) ) [Cost] = SUMX (Sales, [Qty] * [UnitCost]) [Margin]= [Sales] – [Cost] [Margin%]= [Margin] / [Sales]

DAX at work Weight Percent ABC / Pareto Time Period Comparison Customers / Products (distinct count) Many-to-many relationships

Regular CALCULATE syntaxShortened CALCULATE syntax AmountQuotaCustomers = SUM( Orders[Amount] ) / CALCULATE( SUM( Orders[Amount] ), ALL( Customers ) ) AmountQuotaProducts = SUM( Orders[Amount] ) / CALCULATE( SUM( Orders[Amount] ), ALL( Products ) ) OrdersAmount = SUM(Orders[Amount] ) AmountQuotaCustomers = OrdersAmount / OrdersAmount ( ALL( Customers ) ) AmountQuotaProducts = OrdersAmount / OrdersAmount ( ALL( Products ) )

ABC calculation requires calculated column Required attributes for pivot table axies, not measures Calculated Columns for ABC SalesAmount – Sales amount for product, customer, … Cumulated – Cumulated sales amount (descendent order) SortedWeigth – Cumulated Weight Percent (descendent order) ABC Class – A for 70%, B for 20%, C for 10%

ABC / Pareto SalesAmountProduct

ABC / Pareto CumulatedProduct

ABC / Pareto SortedWeightProduct

ABC / Pareto ABC Product

Time Period Comparison Date Table Create a table with dates (like a Date dimension) Use contiguous dates (no missing days) Fields for all required time aggregations (year, month, …) Year to Date – Cumulated value starting from first day of year DATESYTD changes filter context, TOTALYTD avoids CALCULATE Year-To-Date [Amount YTD] = CALCULATE( SUM( Orders[Amount] ), DATESYTD( Dates[Date] ) ) [Amount YTD 2] = TOTALYTD( SUM( Orders[Amount] ), Dates[Date] )

Time Period Comparison Corresponding value on previous year Use DATEADD to change filter context (SAMEPERIODLASTYEAR as alternative) Total value on previous year Use PARALLELPERIOD to get complete period (year) AmountTotPrevYear = CALCULATE( SUM( Orders[Amount] ), PARALLELPERIOD( Dates[Date], -1, YEAR ) ) Previous Year AmountPrevYear = CALCULATE( SUM( Orders[Amount] ), DATEADD( Dates[Date], -1, YEAR ) ) AmountPrevYear2 = CALCULATE( SUM( Orders[Amount] ), SAMEPERIODLASTYEAR( Dates[Date] ) )

Time Period Comparison Moving Annual Total (cumulated value of last 12 months) Use DATESBETWEEN to change filter context Amount 12M= CALCULATE( SUM( Orders[Amount] ), DATESBETWEEN( Dates[Date], NEXTDAY( SAMEPERIODLASTYEAR( LASTDATE( Dates[Date] ) ) ), LASTDATE( Dates[Date] ) ) ) Last 12 months

Number of Unique Customers / Products Distinct Count Measure

DAX syntax similar to Excel formulas Calculated Columns (PowerPivot tables) Measures (Excel pivot tables) Features available in DAX Excel functions (math, statistical, date/time, text, etc.) Aggregation of any expression over a table Table functions (FILTER, RELATEDTABLE, DISTINCT, ecc.) Fetch data across relationships (one-many, many-one) Set or modify evaluation context (ALL, CALCULATE, ecc.) Time Intelligence functions

BIU302 – Enriching Microsoft PowerPivot for Microsoft Excel Applications Using DAX Thursday, June 10 | 9:45 AM - 11:00 AM | Rm 244