SlideShare a Scribd company logo
1 of 32
DAX (DATA ANALYSIS EXPRESSIONS)
FROM ZERO TO HERO

Frederik Vandeputte
Partner @Kohera
President @SQLUG.BE
frederik.vandeputte@kohera.be
AGENDA
• What’s DAX
• Calculated columns
• Calculated measures
• Some common DAX functions
• Working with DAX and Dates
• Define security in the model
• Query the BI Semantic Model
DAX - DATA ANALYSIS EXPRESSION
• Introduced in PowerPivot v1
• DAX = Data Analysis Expressions
• DAX goals
    • Make data analysis really easy
    • Uses relationships defined in PowerPivot/BISM model (no need for VLOOKUP)
•   Excel like Syntax
•   Support for +/- 80 Excel function
•   35 Built in Time Intelligence functions
•   + Additional function
•   SQL Server 2012 – Analysis Services Tabular Models
BI SEMANTIC MODEL: ARCHITECTURE
       Third-party     Reporting                               SharePoint
                                         Excel   PowerPivot
       applications     Services                                Insights




        Databases     LOB Applications   Files   OData Feeds   Cloud Services
WHAT CAN WE DO WITH DAX
• Create calculated columns
• Create (calculated) measures
• Define security in the model
• Query the BI Semantic Model
4 IMPORTANT CONCEPTS

      Calculated       Calculated
       Columns         Measures

         Row             Filter
        Context         Context
CALCULATED COLUMNS
•   Just another column in a table
•   Similar to named calculations in SSAS OLAP Datasource views
•   Calculated after data has been loaded (cube processing)
•   Can be placed in colums, rows, filters and slicers
•   Evaluated in row context
•   Examples
    • [Amount] =[Qty] *[Price]
    • [Full Name]     = [First Name] & “ “ & [Last Name]
CALCULATED MEASURES
• Created in the measure grid
• Calculated “on the fly”
• Can only be placed in values area of PivotTables
• Evaluated in filter context
 • Rows/Columns/filters/Slicers
• Examples
 • [Sales]     = SUM (Sales[Amount])
 • [Average Sale] = AVERAGEX ( Sales, Sales[Amount])
FILTER CONTEXT
• Filter Context = cell in PivotTable




                                            [CalendarYear] = 2008
                                           [ChannelName]=”Store”
                                        [ContinentName]=”Europe”
                                 [RegionCountryName] = “Germany”
MEASURES MUST BE EXPLICITELY CREATED

• PowerPivot will create implicit measures when you drag a column
  to the values area in a pivot table
• Not possible in BISM (No_ measure defined)
• Like in SSAS OLAP – measures must be created explicitely
• Eeasiest way: AutoSum in SQL Data Tools
SOME COMMON DAX FUNCTIONS
• DISTINCTCOUNT()
• RELATED()
• CALCULATE()
RELATED(COLUMN) AND RELATEDTABLE(TABLE)


    • More powerfull than VLOOKUP
      • VLOOKUP only returns 1st match
      • Relies on relationships in PowerPivot
      • Follows many to one relationship
RELATED(COLUMN)

                                            FactSales   • Storekey


• Travels many to one direction
• Can travel multiple relationships                                   •Geograpghy
                                                        DimStore
• Add calculated columns to FactSales
                                                                       Key


  • =RELATED(DimStore[StoreName])
  • =RELATED(DimGeography[ContinentName])
                                                                     DimGeography
CALCULATE(EXPRESSION, SETFILTER1, SETFILTER2, …)
• CALCULATE more complex than previous functions, but
  very powerful
• CALCULATE is the Queen Of DAX
• CALCUATE
 • Using the SetFilter arguments, modify the Filter Context
 • If there is a Row Context, move that Row Context onto the Filter Context
 • Evaluate the Expression in the newly modified Filter Context
DAX AND TIME INTELLIGENCE
• +/- 35 DAX time intelligence functions
• DAX helps you when calculating with dates
• But you must follow the rules
THE GOLDEN RULES WHEN WORKING WITH DATES
• Always create a separate Date table.
• Make sure your date table has a continues date range
• Create relationships between fact tables and the Date
  table.
• Never use the datetime column from the fact table in time
  functions.
• The datetime column in the Date table should be at day
  granularity (without fractions of a day).
• Mark the Date table as a Date Table and set the Date
  column.
IF YOU DON’T HAVE A SEPERATE TIME TABLE  ERRORS
IF YOU HAVE A SEPERATE TIME TABLE  CORRECT VALUES
DATE CALCULATIONS
• TOTALYTD function
  • Calculated Year To Date Values
  • SalesAmtYTD:=TOTALYTD(SUM(AutoSales[SalesAmount]);Dates[Date])




                                             WRONG RESULTS
CREATE A DATE DIMENSION
•   Mark Time Dimension Table as Date
•   Use data column from Time dimension in Calculations
•   Sort Columns By key column
•   Create Hierarchies (in Diagram view)


                        CORRECT RESULTS
CREATE THE PERFECT DATE DIMENSION
• Follow the golden rules
• Sort Columns By key column
• Create Hierarchies
TIME INTELLIGENCE EXAMPLES FOR SALES

     Time Period                Formula
     Current Period             =SUM([SalesAmount])
     MTD                        = CALCULATE(SUM(SalesAmount), DATESMTD(Dates[Date]))


     QTD                        = CALCULATE(SUM(SalesAmount), DATESQTD(Dates[Date]))


     YTD                        = CALCULATE(SUM(SalesAmount), DATESYTD(Dates[Date]))


     Current Period Last Year   = CALCULATE(SUM(SalesAmount), DATEADD(Dates[Date],-1,YEAR))


     PriorYearMTD               = CALCULATE(SUM(SalesAmount),
                                DATEADD(DATESMTD(Dates[Date]),-1,YEAR))
     PriorYearQTD               = CALCULATE(SUM(SalesAmount),
                                DATEADD(DATESQTD(Dates[Date]),-1,YEAR))
     PriorYearYTD               = CALCULATE(SUM(SalesAmount),
                                DATEADD(DATESYTD(Dates[Date]),-1,YEAR))
DAX EDITOR
• Code highlighting
• No intellisense
• Free download at http://daxeditor.codeplex.com/
WHAT CAN WE DO WITH DAX
• Create calculated columns
• Create (calculated) measures
• Define security in the model
• Query the BI Semantic Model
ADD SECURITY TO YOUR MODEL USING DAX
WHAT CAN WE DO WITH DAX
• Create calculated columns
• Create (calculated) measures
• Define security in the model
• Query the BI Semantic Model
DAX QUERIES
[DEFINE { MEASURE <tableName>[<name>] = <expression> }

EVALUATE <table>
[ORDER BY {<expression> [{ASC | DESC}]}[, …]
  [START AT {<value>|<parameter>} [, …]]]
DAX QUERIES IN REPORTING SERVICES (SQL DATA TOOLS)
• Create SSAS DataSource
• Create Dataset
• In Query Designer
  • Switch to Command Type DMX
  • Switch to Design Mode
  • Define Parameters
DAX QUERIES IN REPORT BUILDER
•   Query designer does not support DMX!!
•   Create OLEDB Datasource
•   Create Dataset
•   Write the query as an expression
    and concatenate using
    Parameters.ParamName.Value
SO, WHAT CAN WE DO WITH DAX
• Create calculated columns
• Create (calculated) measures
• Define security in the model
• Query the BI Semantic Model

• DAX is Simple, but it’s not always Easy
SOME RESOURCES
• Blogs
  •   http://www.vandeputte.org (Frederik Vandeputte)
  •   http://www.powerpivotblog.nl/ (Kasper De Jonge)
  •   http://sqlblog.com/blogs/marco_russo/ (Marco Russo)
  •   http://sqlblog.com/blogs/alberto_ferrari/ (Alberto Ferrari)
  •   http://cwebbbi.wordpress.com/ (Chriss Webb)
  •   http://javierguillen.wordpress.com/ (Javier Guillén)
• Sites
  • http://social.technet.microsoft.com/wiki/contents/articles/277.powerpivot-
    overview.aspx (PowerPivot Wiki)
  • http://www.powerpivot-info.com/
  • http://www.ssas-info.com
  • www.sqlug.be
  • www.kohera.be
THANK YOU

More Related Content

What's hot

DAX and Power BI Training - 004 Power Query
DAX and Power BI Training - 004 Power QueryDAX and Power BI Training - 004 Power Query
DAX and Power BI Training - 004 Power QueryWill Harvey
 
Tableau LOD Expressions | Edureka
Tableau LOD Expressions | EdurekaTableau LOD Expressions | Edureka
Tableau LOD Expressions | EdurekaEdureka!
 
Power BI Data Modeling.pdf
Power BI Data Modeling.pdfPower BI Data Modeling.pdf
Power BI Data Modeling.pdfVishnuGone
 
What are Tableau Functions? Edureka
What are Tableau Functions? EdurekaWhat are Tableau Functions? Edureka
What are Tableau Functions? EdurekaEdureka!
 
Power BI Overview
Power BI OverviewPower BI Overview
Power BI OverviewJames Serra
 
Tableau Visual Guidebook
Tableau Visual GuidebookTableau Visual Guidebook
Tableau Visual GuidebookAndy Kriebel
 
Tableau Software - Business Analytics and Data Visualization
Tableau Software - Business Analytics and Data VisualizationTableau Software - Business Analytics and Data Visualization
Tableau Software - Business Analytics and Data Visualizationlesterathayde
 
Power pivot intro
Power pivot introPower pivot intro
Power pivot introasantaballa
 
Power BI: From the Basics
Power BI: From the BasicsPower BI: From the Basics
Power BI: From the BasicsNikkia Carter
 
Data Analysis with MS Excel.pptx
Data Analysis with MS Excel.pptxData Analysis with MS Excel.pptx
Data Analysis with MS Excel.pptxKouros Goodarzi
 
Tableau And Data Visualization - Get Started
Tableau And Data Visualization - Get StartedTableau And Data Visualization - Get Started
Tableau And Data Visualization - Get StartedSpotle.ai
 
Basic introduction to power query
Basic introduction to power queryBasic introduction to power query
Basic introduction to power querydisha parmar
 

What's hot (20)

DAX and Power BI Training - 004 Power Query
DAX and Power BI Training - 004 Power QueryDAX and Power BI Training - 004 Power Query
DAX and Power BI Training - 004 Power Query
 
Data Modeling with Power BI
Data Modeling with Power BIData Modeling with Power BI
Data Modeling with Power BI
 
PowerBI Training
PowerBI Training PowerBI Training
PowerBI Training
 
My tableau
My tableauMy tableau
My tableau
 
Power query
Power queryPower query
Power query
 
Tableau LOD Expressions | Edureka
Tableau LOD Expressions | EdurekaTableau LOD Expressions | Edureka
Tableau LOD Expressions | Edureka
 
Power BI Data Modeling.pdf
Power BI Data Modeling.pdfPower BI Data Modeling.pdf
Power BI Data Modeling.pdf
 
What are Tableau Functions? Edureka
What are Tableau Functions? EdurekaWhat are Tableau Functions? Edureka
What are Tableau Functions? Edureka
 
Power BI Overview
Power BI OverviewPower BI Overview
Power BI Overview
 
Tableau Visual Guidebook
Tableau Visual GuidebookTableau Visual Guidebook
Tableau Visual Guidebook
 
Tableau Software - Business Analytics and Data Visualization
Tableau Software - Business Analytics and Data VisualizationTableau Software - Business Analytics and Data Visualization
Tableau Software - Business Analytics and Data Visualization
 
Power BI for Developers
Power BI for DevelopersPower BI for Developers
Power BI for Developers
 
Power BI Overview
Power BI OverviewPower BI Overview
Power BI Overview
 
Power pivot intro
Power pivot introPower pivot intro
Power pivot intro
 
Power BI: From the Basics
Power BI: From the BasicsPower BI: From the Basics
Power BI: From the Basics
 
Data Analysis with MS Excel.pptx
Data Analysis with MS Excel.pptxData Analysis with MS Excel.pptx
Data Analysis with MS Excel.pptx
 
Tableau And Data Visualization - Get Started
Tableau And Data Visualization - Get StartedTableau And Data Visualization - Get Started
Tableau And Data Visualization - Get Started
 
Power bi
Power biPower bi
Power bi
 
Power bi overview
Power bi overview Power bi overview
Power bi overview
 
Basic introduction to power query
Basic introduction to power queryBasic introduction to power query
Basic introduction to power query
 

Similar to DAX (Data Analysis eXpressions) from Zero to Hero

Pass 2018 introduction to dax
Pass 2018 introduction to daxPass 2018 introduction to dax
Pass 2018 introduction to daxIke Ellis
 
3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sql3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sqlŁukasz Grala
 
Introduction-to-DAX-2017-01-12.pptx
Introduction-to-DAX-2017-01-12.pptxIntroduction-to-DAX-2017-01-12.pptx
Introduction-to-DAX-2017-01-12.pptxKishor kumar M
 
Real-world BISM in SQL Server 2012 SSAS
Real-world BISM in SQL Server 2012 SSASReal-world BISM in SQL Server 2012 SSAS
Real-world BISM in SQL Server 2012 SSASLynn Langit
 
Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...
Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...
Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...Julian Hyde
 
2015 NCAIR Excel Power Tools
2015 NCAIR Excel Power Tools2015 NCAIR Excel Power Tools
2015 NCAIR Excel Power ToolsDavid Onder
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence PortfolioChris Seebacher
 
Excel patterns in Power BI: From Excel hero to Power BI Champion
Excel patterns in Power BI: From Excel hero to Power BI ChampionExcel patterns in Power BI: From Excel hero to Power BI Champion
Excel patterns in Power BI: From Excel hero to Power BI ChampionIsabelle Van Campenhoudt
 
Chris Seebacher Portfolio
Chris Seebacher PortfolioChris Seebacher Portfolio
Chris Seebacher Portfolioguest3ea163
 
DataSaturday #1 - PBI Modeling At Warp Speed With Tabular Editor Advanced Scr...
DataSaturday #1 - PBI Modeling At Warp Speed With Tabular Editor Advanced Scr...DataSaturday #1 - PBI Modeling At Warp Speed With Tabular Editor Advanced Scr...
DataSaturday #1 - PBI Modeling At Warp Speed With Tabular Editor Advanced Scr...Riccardo Perico
 
Advanced integration services on microsoft ssis 1
Advanced integration services on microsoft ssis 1Advanced integration services on microsoft ssis 1
Advanced integration services on microsoft ssis 1Skillwise Group
 
Implementing Tables and Views.pptx
Implementing Tables and Views.pptxImplementing Tables and Views.pptx
Implementing Tables and Views.pptxLuisManuelUrbinaAmad
 
Alasql JavaScript SQL Database Library: User Manual
Alasql JavaScript SQL Database Library: User ManualAlasql JavaScript SQL Database Library: User Manual
Alasql JavaScript SQL Database Library: User ManualAndrey Gershun
 
Power BI / AAS Model Optimization
Power BI / AAS Model OptimizationPower BI / AAS Model Optimization
Power BI / AAS Model OptimizationDan English
 
Power BI / AAS Data Model Optimization 101 v2
Power BI / AAS Data Model Optimization 101 v2Power BI / AAS Data Model Optimization 101 v2
Power BI / AAS Data Model Optimization 101 v2Dan English
 

Similar to DAX (Data Analysis eXpressions) from Zero to Hero (20)

Pass 2018 introduction to dax
Pass 2018 introduction to daxPass 2018 introduction to dax
Pass 2018 introduction to dax
 
3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sql3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sql
 
Introduction-to-DAX-2017-01-12.pptx
Introduction-to-DAX-2017-01-12.pptxIntroduction-to-DAX-2017-01-12.pptx
Introduction-to-DAX-2017-01-12.pptx
 
Real-world BISM in SQL Server 2012 SSAS
Real-world BISM in SQL Server 2012 SSASReal-world BISM in SQL Server 2012 SSAS
Real-world BISM in SQL Server 2012 SSAS
 
Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...
Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...
Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...
 
2015 NCAIR Excel Power Tools
2015 NCAIR Excel Power Tools2015 NCAIR Excel Power Tools
2015 NCAIR Excel Power Tools
 
Hello my name is DAX
Hello my name is DAXHello my name is DAX
Hello my name is DAX
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
 
SQLDay2013_ChrisWebb_DAXMD
SQLDay2013_ChrisWebb_DAXMDSQLDay2013_ChrisWebb_DAXMD
SQLDay2013_ChrisWebb_DAXMD
 
Vertica-Database
Vertica-DatabaseVertica-Database
Vertica-Database
 
Excel patterns in Power BI: From Excel hero to Power BI Champion
Excel patterns in Power BI: From Excel hero to Power BI ChampionExcel patterns in Power BI: From Excel hero to Power BI Champion
Excel patterns in Power BI: From Excel hero to Power BI Champion
 
Getting power bi
Getting power biGetting power bi
Getting power bi
 
Chris Seebacher Portfolio
Chris Seebacher PortfolioChris Seebacher Portfolio
Chris Seebacher Portfolio
 
From Excel hero to Power BI champion
From Excel hero to Power BI championFrom Excel hero to Power BI champion
From Excel hero to Power BI champion
 
DataSaturday #1 - PBI Modeling At Warp Speed With Tabular Editor Advanced Scr...
DataSaturday #1 - PBI Modeling At Warp Speed With Tabular Editor Advanced Scr...DataSaturday #1 - PBI Modeling At Warp Speed With Tabular Editor Advanced Scr...
DataSaturday #1 - PBI Modeling At Warp Speed With Tabular Editor Advanced Scr...
 
Advanced integration services on microsoft ssis 1
Advanced integration services on microsoft ssis 1Advanced integration services on microsoft ssis 1
Advanced integration services on microsoft ssis 1
 
Implementing Tables and Views.pptx
Implementing Tables and Views.pptxImplementing Tables and Views.pptx
Implementing Tables and Views.pptx
 
Alasql JavaScript SQL Database Library: User Manual
Alasql JavaScript SQL Database Library: User ManualAlasql JavaScript SQL Database Library: User Manual
Alasql JavaScript SQL Database Library: User Manual
 
Power BI / AAS Model Optimization
Power BI / AAS Model OptimizationPower BI / AAS Model Optimization
Power BI / AAS Model Optimization
 
Power BI / AAS Data Model Optimization 101 v2
Power BI / AAS Data Model Optimization 101 v2Power BI / AAS Data Model Optimization 101 v2
Power BI / AAS Data Model Optimization 101 v2
 

More from Microsoft TechNet - Belgium and Luxembourg

More from Microsoft TechNet - Belgium and Luxembourg (20)

Windows 10: all you need to know!
Windows 10: all you need to know!Windows 10: all you need to know!
Windows 10: all you need to know!
 
Configuration Manager 2012 – Compliance Settings 101 - Tim de Keukelaere
Configuration Manager 2012 – Compliance Settings 101 - Tim de KeukelaereConfiguration Manager 2012 – Compliance Settings 101 - Tim de Keukelaere
Configuration Manager 2012 – Compliance Settings 101 - Tim de Keukelaere
 
Windows 8.1 a closer look
Windows 8.1 a closer lookWindows 8.1 a closer look
Windows 8.1 a closer look
 
So you’ve successfully installed SCOM… Now what.
So you’ve successfully installed SCOM… Now what.So you’ve successfully installed SCOM… Now what.
So you’ve successfully installed SCOM… Now what.
 
Data Leakage Prevention
Data Leakage PreventionData Leakage Prevention
Data Leakage Prevention
 
Deploying and managing ConfigMgr Clients
Deploying and managing ConfigMgr ClientsDeploying and managing ConfigMgr Clients
Deploying and managing ConfigMgr Clients
 
Self Service BI anno 2013 – Where Do We Come From and Where Are We Going?
Self Service BI anno 2013 – Where Do We Come From and Where Are We Going?Self Service BI anno 2013 – Where Do We Come From and Where Are We Going?
Self Service BI anno 2013 – Where Do We Come From and Where Are We Going?
 
Hands on with Hyper-V Clustering Maintenance Mode & Cluster Aware Updating
Hands on with Hyper-V Clustering Maintenance Mode & Cluster Aware UpdatingHands on with Hyper-V Clustering Maintenance Mode & Cluster Aware Updating
Hands on with Hyper-V Clustering Maintenance Mode & Cluster Aware Updating
 
SCEP 2012 inside SCCM 2012
SCEP 2012 inside SCCM 2012SCEP 2012 inside SCCM 2012
SCEP 2012 inside SCCM 2012
 
Jump start your application monitoring with APM
Jump start your application monitoring with APMJump start your application monitoring with APM
Jump start your application monitoring with APM
 
What’s new in Lync Server 2013: Persistent Chat
What’s new in Lync Server 2013: Persistent ChatWhat’s new in Lync Server 2013: Persistent Chat
What’s new in Lync Server 2013: Persistent Chat
 
What's new for Lync 2013 Clients & Devices
What's new for Lync 2013 Clients & DevicesWhat's new for Lync 2013 Clients & Devices
What's new for Lync 2013 Clients & Devices
 
Office 365 ProPlus: Click-to-run deployment and management
Office 365 ProPlus: Click-to-run deployment and managementOffice 365 ProPlus: Click-to-run deployment and management
Office 365 ProPlus: Click-to-run deployment and management
 
Office 365 Identity Management options
Office 365 Identity Management options Office 365 Identity Management options
Office 365 Identity Management options
 
SharePoint Installation and Upgrade: Untangling Your Options
SharePoint Installation and Upgrade: Untangling Your Options SharePoint Installation and Upgrade: Untangling Your Options
SharePoint Installation and Upgrade: Untangling Your Options
 
The application model in real life
The application model in real lifeThe application model in real life
The application model in real life
 
Microsoft private cloud with Cisco and Netapp - Flexpod solution
Microsoft private cloud with Cisco and Netapp -  Flexpod solutionMicrosoft private cloud with Cisco and Netapp -  Flexpod solution
Microsoft private cloud with Cisco and Netapp - Flexpod solution
 
Managing Windows RT devices in the Enterprise
Managing Windows RT devices in the Enterprise Managing Windows RT devices in the Enterprise
Managing Windows RT devices in the Enterprise
 
Moving from Device Centric to a User Centric Management
Moving from Device Centric to a User Centric Management Moving from Device Centric to a User Centric Management
Moving from Device Centric to a User Centric Management
 
Network Management in System Center 2012 SP1 - VMM
Network Management in System Center 2012  SP1 - VMM Network Management in System Center 2012  SP1 - VMM
Network Management in System Center 2012 SP1 - VMM
 

Recently uploaded

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

DAX (Data Analysis eXpressions) from Zero to Hero

  • 1. DAX (DATA ANALYSIS EXPRESSIONS) FROM ZERO TO HERO Frederik Vandeputte Partner @Kohera President @SQLUG.BE frederik.vandeputte@kohera.be
  • 2. AGENDA • What’s DAX • Calculated columns • Calculated measures • Some common DAX functions • Working with DAX and Dates • Define security in the model • Query the BI Semantic Model
  • 3. DAX - DATA ANALYSIS EXPRESSION • Introduced in PowerPivot v1 • DAX = Data Analysis Expressions • DAX goals • Make data analysis really easy • Uses relationships defined in PowerPivot/BISM model (no need for VLOOKUP) • Excel like Syntax • Support for +/- 80 Excel function • 35 Built in Time Intelligence functions • + Additional function • SQL Server 2012 – Analysis Services Tabular Models
  • 4. BI SEMANTIC MODEL: ARCHITECTURE Third-party Reporting SharePoint Excel PowerPivot applications Services Insights Databases LOB Applications Files OData Feeds Cloud Services
  • 5. WHAT CAN WE DO WITH DAX • Create calculated columns • Create (calculated) measures • Define security in the model • Query the BI Semantic Model
  • 6. 4 IMPORTANT CONCEPTS Calculated Calculated Columns Measures Row Filter Context Context
  • 7. CALCULATED COLUMNS • Just another column in a table • Similar to named calculations in SSAS OLAP Datasource views • Calculated after data has been loaded (cube processing) • Can be placed in colums, rows, filters and slicers • Evaluated in row context • Examples • [Amount] =[Qty] *[Price] • [Full Name] = [First Name] & “ “ & [Last Name]
  • 8. CALCULATED MEASURES • Created in the measure grid • Calculated “on the fly” • Can only be placed in values area of PivotTables • Evaluated in filter context • Rows/Columns/filters/Slicers • Examples • [Sales] = SUM (Sales[Amount]) • [Average Sale] = AVERAGEX ( Sales, Sales[Amount])
  • 9. FILTER CONTEXT • Filter Context = cell in PivotTable [CalendarYear] = 2008 [ChannelName]=”Store” [ContinentName]=”Europe” [RegionCountryName] = “Germany”
  • 10. MEASURES MUST BE EXPLICITELY CREATED • PowerPivot will create implicit measures when you drag a column to the values area in a pivot table • Not possible in BISM (No_ measure defined) • Like in SSAS OLAP – measures must be created explicitely • Eeasiest way: AutoSum in SQL Data Tools
  • 11. SOME COMMON DAX FUNCTIONS • DISTINCTCOUNT() • RELATED() • CALCULATE()
  • 12. RELATED(COLUMN) AND RELATEDTABLE(TABLE) • More powerfull than VLOOKUP • VLOOKUP only returns 1st match • Relies on relationships in PowerPivot • Follows many to one relationship
  • 13. RELATED(COLUMN) FactSales • Storekey • Travels many to one direction • Can travel multiple relationships •Geograpghy DimStore • Add calculated columns to FactSales Key • =RELATED(DimStore[StoreName]) • =RELATED(DimGeography[ContinentName]) DimGeography
  • 14. CALCULATE(EXPRESSION, SETFILTER1, SETFILTER2, …) • CALCULATE more complex than previous functions, but very powerful • CALCULATE is the Queen Of DAX • CALCUATE • Using the SetFilter arguments, modify the Filter Context • If there is a Row Context, move that Row Context onto the Filter Context • Evaluate the Expression in the newly modified Filter Context
  • 15. DAX AND TIME INTELLIGENCE • +/- 35 DAX time intelligence functions • DAX helps you when calculating with dates • But you must follow the rules
  • 16. THE GOLDEN RULES WHEN WORKING WITH DATES • Always create a separate Date table. • Make sure your date table has a continues date range • Create relationships between fact tables and the Date table. • Never use the datetime column from the fact table in time functions. • The datetime column in the Date table should be at day granularity (without fractions of a day). • Mark the Date table as a Date Table and set the Date column.
  • 17. IF YOU DON’T HAVE A SEPERATE TIME TABLE  ERRORS
  • 18. IF YOU HAVE A SEPERATE TIME TABLE  CORRECT VALUES
  • 19. DATE CALCULATIONS • TOTALYTD function • Calculated Year To Date Values • SalesAmtYTD:=TOTALYTD(SUM(AutoSales[SalesAmount]);Dates[Date]) WRONG RESULTS
  • 20. CREATE A DATE DIMENSION • Mark Time Dimension Table as Date • Use data column from Time dimension in Calculations • Sort Columns By key column • Create Hierarchies (in Diagram view) CORRECT RESULTS
  • 21. CREATE THE PERFECT DATE DIMENSION • Follow the golden rules • Sort Columns By key column • Create Hierarchies
  • 22. TIME INTELLIGENCE EXAMPLES FOR SALES Time Period Formula Current Period =SUM([SalesAmount]) MTD = CALCULATE(SUM(SalesAmount), DATESMTD(Dates[Date])) QTD = CALCULATE(SUM(SalesAmount), DATESQTD(Dates[Date])) YTD = CALCULATE(SUM(SalesAmount), DATESYTD(Dates[Date])) Current Period Last Year = CALCULATE(SUM(SalesAmount), DATEADD(Dates[Date],-1,YEAR)) PriorYearMTD = CALCULATE(SUM(SalesAmount), DATEADD(DATESMTD(Dates[Date]),-1,YEAR)) PriorYearQTD = CALCULATE(SUM(SalesAmount), DATEADD(DATESQTD(Dates[Date]),-1,YEAR)) PriorYearYTD = CALCULATE(SUM(SalesAmount), DATEADD(DATESYTD(Dates[Date]),-1,YEAR))
  • 23. DAX EDITOR • Code highlighting • No intellisense • Free download at http://daxeditor.codeplex.com/
  • 24. WHAT CAN WE DO WITH DAX • Create calculated columns • Create (calculated) measures • Define security in the model • Query the BI Semantic Model
  • 25. ADD SECURITY TO YOUR MODEL USING DAX
  • 26. WHAT CAN WE DO WITH DAX • Create calculated columns • Create (calculated) measures • Define security in the model • Query the BI Semantic Model
  • 27. DAX QUERIES [DEFINE { MEASURE <tableName>[<name>] = <expression> } EVALUATE <table> [ORDER BY {<expression> [{ASC | DESC}]}[, …] [START AT {<value>|<parameter>} [, …]]]
  • 28. DAX QUERIES IN REPORTING SERVICES (SQL DATA TOOLS) • Create SSAS DataSource • Create Dataset • In Query Designer • Switch to Command Type DMX • Switch to Design Mode • Define Parameters
  • 29. DAX QUERIES IN REPORT BUILDER • Query designer does not support DMX!! • Create OLEDB Datasource • Create Dataset • Write the query as an expression and concatenate using Parameters.ParamName.Value
  • 30. SO, WHAT CAN WE DO WITH DAX • Create calculated columns • Create (calculated) measures • Define security in the model • Query the BI Semantic Model • DAX is Simple, but it’s not always Easy
  • 31. SOME RESOURCES • Blogs • http://www.vandeputte.org (Frederik Vandeputte) • http://www.powerpivotblog.nl/ (Kasper De Jonge) • http://sqlblog.com/blogs/marco_russo/ (Marco Russo) • http://sqlblog.com/blogs/alberto_ferrari/ (Alberto Ferrari) • http://cwebbbi.wordpress.com/ (Chriss Webb) • http://javierguillen.wordpress.com/ (Javier Guillén) • Sites • http://social.technet.microsoft.com/wiki/contents/articles/277.powerpivot- overview.aspx (PowerPivot Wiki) • http://www.powerpivot-info.com/ • http://www.ssas-info.com • www.sqlug.be • www.kohera.be

Editor's Notes

  1. Carry forward the existing ecosystem of client applicationsLook a bit deeper into the conceptual architectureCall out PowerPivot as a clientMDX versus DAXData access: cache the data or pass it through Vertipaq new in-memorycolunmstore, compression, blazing fast perf. No aggregations or tuning. Same as PowerPivot for Excel and SharePoint.