Presentation is loading. Please wait.

Presentation is loading. Please wait.

Modeling scenarios for DAX

Similar presentations


Presentation on theme: "Modeling scenarios for DAX"— Presentation transcript:

1 Modeling scenarios for DAX
Ana María Bisbé York Business Intelligence Consultant MS Partner on Power BI @ambynet Modeling scenarios for DAX

2 Thanks to all Sponsors

3 Say thanks to our volunteers
They spend their FREE time to give you this event. Because they are crazy.  Because they want YOU to learn from the BEST IN THE WORLD. João Sarmento Eduardo Piairo Diamantino Falcão

4 Agenda Intro Decisions to take: Evaluation context
Implicit vs Explicit Measures Calculated columns vs measures Measures vs Variables Calculated columns vs Calculated Tables Calculated columns vs Measures vs Context transition Evaluation context Definition Test the quality of data Modify current filter context

5 DAX - Introduction DAX – Data Analysis Expressions Tabular models
Power Pivot SQL Server Analysis Services Tabular Power BI Functional language Execution flows as function calls From inner to outer most Single line execution

6 Is it easy to write DAX expressions?

7 Demo !!! 

8 Is it easy to write DAX expressions?

9 Decisions to take !!

10 Calculated column vs Measures
Design of the model Calculated column, (preferably during the Query step) Headers of rows and/or columns of a table or matrix, discrete axis in charts or slicers Measures (with DAX) Examine the result as value, in the central panel of the pivot table Use this value as data source for the KPI Value depends on the user-defined context Affected by table filters, charts and slicers

11 Explicit measures vs Columns
Implicit measures are created when a numeric column is selected. The default aggregate function is Sum Good practices: Create the measure It’s easier to read and to maintain the code From them on, we can always select the Total Quantity measure. We do not need the table name to refer to the measure, the measures belong to the model. Explicit measures are wrapped in a CALCULATE, although we don’t write it CALCULATE creates the transition from the row context into filter context. This avoids the use of navigation functions, which once again improves reading and maintenance. When exporting the model to Excel, the measures are available for the ”pivot table values”, numeric columns, in the other hand, are not.

12 Calculated columns vs measures
Two types of calculations in DAX Calculated columns It is evaluated row by row It consumes more resources, calculates for every row of the column Immediate calculation and storage in column of the tabular model Useful for filters and segmentation. Best Practices: Creating calculated columns in a query. Do not create calculated columns for numeric values Measures It is evaluated by using on a table/chart It consumes less resources, only calculated for active elements. Dynamic calculation, on the fly Written always in DAX, same syntax, different context

13 Calculated columns vs measures
Calculations from columns Calculations from measures

14 Measures vs Variables Variables More readable code
Less evaluation for each function No additional measure is created

15 Model types Unique table Snowflake Star
Excel classic, before Excel 2013 Snowflake Normalized There are links between the search tables or directly to the facts tables. Star Denormalized model All search tables (dimensions) point directly to the facts table

16 Relationships between tables and DAX
Combined filters from different tables All tables are pointing to Facts Tables

17 Relationships between tables and DAX
Crossfilter direction Single direction in the model  Need to filter in both directions  Both directions in the calculation or in the model?

18 Relationships between tables and DAX
Crossed filter direction: bidirectional The filter from Products propagates to Sales(1:M) The filter propagates from Sales to Customers(M:1) Caution – could be very dangerous 

19 Relationships between tables and DAX
Crossfilter direction Single direction in the model Both directions in the calculation !! DAX to the rescue !!!

20 Calculated columns vs Calculated tables
Table with a single column Calculated column

21 Calculated columns vs Calculated tables
Tables created with columns, single DAX expression

22 Evaluation context

23 DAX Contexts Different results of a measure, depending on context
The result depends on: The code The filter context in which is evaluated

24 Testing context with FILTER
Given a context Create a temporary table to test the value Calculate the aggregated in a measurement

25 Testing context with FILTER
Given a context Calculate the aggregated of a measure, using directly the filter expression

26 Modifying context with DAX
Replace the existing FILTER context With functions CALCULATE or CALCULATETABLE Ignore existing context With function ALL

27 Modifying context with DAX
Replace or Ignore existing context Only when it corresponds Analysis done by category Nothing to replace or ignore ignorar

28 Modifying context with DAX
Contexts and comparisons Compare in a single category Exclude total value

29 Modifying context with DAX – April 2017
Quick measures – (preview versión)

30 Modifying context with DAX – Abril 2017
Surprise! Power BI Desktop writes DAX  Quick measures

31 Resources Books Tools

32 DAX - Recap It is easy to start writing DAX expressions for tabular models Very powerful, and delicate at the same time Measures and CALCULATE are our best allies #HappyDAXing 

33 Questions? Ana María Bisbé York Thanks!!! #sqlsatPorto #sqlsat685


Download ppt "Modeling scenarios for DAX"

Similar presentations


Ads by Google