SlideShare a Scribd company logo
1 of 34
Michael P. Antonovich
Blog: http://SharePointMike.WordPress.com
IT PRO Camp - Jacksonville 2012
•   User‟s Guide to the Apple ][ - 1983
•   FoxPro 2 Programming Guide – 1992
•   Debugging and Maintaining FoxPro – 1992
•   Using Visual FoxPro 3.0 – 1995
•   Using Visual FoxPro 5.0 – 1996
•   Office and SharePoint User’s Guide – 2007
•   Office and SharePoint User’s Guide – 2010

    Speaker at:
        Code Camp 2009, 2010, 2011, 2012 Orlando
        SharePoint Saturday 2011 Tampa, 2012 Orlando
        SQL Saturday - #1, #4, #8, #10, #15, #16, #21, #32, #38, #49, #62, #74, #79, #85,
        #86, #110, #130

6/16/2012                        IT Pro Camp - Jacksonville 2012                        2
• DAX stands for: Data Analysis Expressions

• DAX is used in PowerPivot to:
    • Create calculated columns
    • Create custom measures




6/16/2012                IT Pro Camp - Jacksonville 2012   3
• Aggregate – A mathematical function that allows you to
  summarize values of an attribute
• Dimension - A dimension is essentially a look-up table that
  may define a hierarchy or drill-down path such as Year >
  Quarter > Month
• Measure – A measure is something that identifies a value
• Fact – A fact is another term for a measure that contains
  numeric data that can be grouped along one or more
  dimensional hierarchy
• Star Schema – All dimension tables radiate out from a single
  fact table
• Snowflake Schema – One fact table may relate to another
  fact table before relating to dimension tables. One dimension
  table can also have a related dimension table
• A Pivot table or chart is usually based around a single fact
  table
6/16/2012              IT Pro Camp - Jacksonville 2012            4
•   PowerPivot is a data analysis tool
•   PowerPivot is a free download from Microsoft
•   PowerPivot lets you process millions of rows of data
•   PowerPivot uses as much memory as available & multi-cores
•   PowerPivot lets you integrate data from multiple sources
•   PowerPivot lets you explore, analyze and create analysis
•   PowerPivot was originally called: Project „Gemini‟



    6/16/2012          IT Pro Camp - Jacksonville 2012    5
•   32-or 64 bit Operating System
•   1 GB of RAM, 2 GB recommended (or more)
•   Windows XP with SP3, Vista with SP1, Windows 7
•   .NET Framework 3.5 SP1 or better
•   Microsoft Office 2010




6/16/2012            IT Pro Camp - Jacksonville 2012   6
• Fewer data requests since staff can slice and dice
  their own data
• More control over data other people can access
• Users can generate their own reports
• PowerPivot gives SQL Server data access to the
  masses



6/16/2012         IT Pro Camp - Jacksonville 2012   7
• Simple Calculations
    • Calculated columns within fact tables
    • Calculated columns for dimension tables
    • Calculated columns between tables
    • Calculated columns to serve as links to tables using multiple
      columns
    (Calculated columns are calculated for every row in the table)


• Aggregate Calculations
    • Calculate unique measures
    (Aggregate measures are only calculated for the displayed data in
    the Pivot table)

6/16/2012                  IT Pro Camp - Jacksonville 2012              8
• Comprised of 135 functions
• 71 functions are similar to Excel functions
    • 69 have the same name – 2 do not
       • TEXT  FORMAT
       • DATEDIF  YEARFRAC
• 64 functions are unique to DAX
    • Aggregate data functions
    • Date related functions




6/16/2012                 IT Pro Camp - Jacksonville 2012   9
• DAX expressions always begin with an equal sign: =
• Column References can be qualified or unqualified
    • TableName[ColumnName]
    • [ColumnName]




6/16/2012             IT Pro Camp - Jacksonville 2012   10
6/16/2012   IT Pro Camp - Jacksonville 2012   11
• To concatenate first and last name:
   = Table1[First_Name] & “-” & Table2[Last_Name]


 • To calculate a new measure value like Total_Profit
   = Table1[Total_Revenue] – Table1[Total Cost] –
   Table1[Returns]




6/16/2012           IT Pro Camp - Jacksonville 2012     12
6/16/2012   IT Pro Camp - Jacksonville 2012   13
6/16/2012   IT Pro Camp - Jacksonville 2012   14
• Wrong way
    = DimProduct(Unit_Price) – DimProduct(Unit_Cost)


• Right way
    = RELATED(DimProduct(Unit_Price)) –
    RELATED(DimProduct(Unit_Cost))




6/16/2012                IT Pro Camp - Jacksonville 2012   15
6/16/2012   IT Pro Camp - Jacksonville 2012   16
6/16/2012   IT Pro Camp - Jacksonville 2012   17
• Often you will need to build a Date Dimension table
  based on the minimum and maximum dates in your fact
  table.

• Date Dimension tables are relatively easy to build using
  DAX formulas. Or you can build them in SQL Server
  using T-SQL. You can even build the table in Excel and
  use standard Excel functions.




6/16/2012            IT Pro Camp - Jacksonville 2012         18
=DATE(<year>, <month>, <day>)
            =DATEVALUE(<date_text>)
            =DAY(<date>)
            =EDATE(<start_date>, <months>)
            =EOMONTH(<start_date>, <months>)
            =HOUR(<datetime>)
            =MINUTE(<datetime>)
            =MONTH(<datetime>)
            =NOW()
            =SECOND(<datetime>)
            =TIME(<hour>, <minute>, <second>)
            =TIMEVALUE(<time_text>)
            =TODAY()
            =WEEKDAY(<datetime>)
            =WEEKNUM(<date>, <return_type>)
            =YEAR(<date>)
            =YEARFRAC(<start_date>, <end_date>, <basis>)


6/16/2012             IT Pro Camp - Jacksonville 2012      19
• Get the Year:
       =YEAR(Patient_Vaccinations[VisitDate])

• Get Month Number:
      =FORMAT(MONTH(Patient_Vaccinations[VisitDate]),"00"
)
      =FORMAT(Patient_Vaccinations[VisitDate],”MM”)

• Get name of the month
       =FORMAT(Patient_Vaccinations[VisitDate],"MMM")

• Get name of the week day
       =FORMAT(WEEKDAY(Patient_Vaccinations[VisitDate]),
             "dddd")
6/16/2012             IT Pro Camp - Jacksonville 2012      20
• Calculating Quarter of Year
       =INT((MONTH(Patient_Vaccinations[VisitDate])-
1)/3)+1

• Calculating Quarter of Year Name
      ="Qtr " &
INT((MONTH(Patient_Vaccinations[VisitDate])-
              1)/3)+1

• Get week number of year
      =WEEKNUM(Patient_Vaccinations[VisitDate])
6/16/2012           IT Pro Camp - Jacksonville 2012    21
6/16/2012   IT Pro Camp - Jacksonville 2012   22
• Problem:
    • PowerPivot can only link two tables based on a single column.
    • You need to link two tables using two or more columns.


• Solution:
    • Use DAX to create a calculated column that combines the data
      from the two columns in each table.
    • Typically when combining the data from multiple columns, it
      implies first a conversion of the column data to strings and then
      the string versions of the column data are the concatenated.



6/16/2012                  IT Pro Camp - Jacksonville 2012                23
6/16/2012   IT Pro Camp - Jacksonville 2012   24
• Standard measures are aggregated using one of the following
  aggregate functions:


            • COUNTA (count non-empty cells)
            • SUM
            • MIN
            • MAX
            • AVERAGE

Note: List says COUNT, not COUNTA but it uses the COUNTA
function
6/16/2012             IT Pro Camp - Jacksonville 2012       25
• When you right click a measure, you can select from one of
  the following calculation types:
    •   % of Grand Total
    •   % of Column Total
    •   % of Row Total
    •   % of …
    •   % of Parent Row Total
    •   % of Parent Column Total
    •   % of Parent Total …
    •   Difference from …
    •   % Difference from …
    •   Running Total In …
    •   Rank Smallest to Largest …
    •   Rank Largest to Smallest …

6/16/2012                   IT Pro Camp - Jacksonville 2012    26
% of Parent Row




            % of Grand Total



6/16/2012                      IT Pro Camp - Jacksonville 2012                     27
• Sometimes you need a DAX measure that is not built-in.
   For example, suppose you want to display the number of
   distinct values as a function of other dimensions, not a
   total count.




6/16/2012            IT Pro Camp - Jacksonville 2012      28
6/16/2012   IT Pro Camp - Jacksonville 2012   29
• COUNT – Number of cells that contain numbers
• COUNTA – Number of cells that contain numbers or
  blanks
• COUNTBLANK – Counts blank cells in a column
• AVERAGEA – Average based on all non-empty cells
• MAXA – Largest value in column including blanks and
  logical values
• MINA - Smallest value in column including blanks and
  logical values
• CALCULATE – Overrides existing pivot table filters
• FILTER – Applies against existing pivot table filters
6/16/2012            IT Pro Camp - Jacksonville 2012      30
• DAX expressions are calculated independently for every
  cell, even total rows and total columns
• One DAX expression can include another embedded
  DAX expression. (average profit per visit)
            = SUM(FactSales[TotalProfit]) / FactSales[DistinctSales]
    By default, DAX expressions obey filters. Sometime you
    need to ignore filters as in: (This is the same as % of
    Total)
    =SUM(FactSales[TotalProfit])/
         CALCULATE(SUM(FactSales[TotalProfit]),ALL(FactSales))
 • There are 35 time intelligence functions not covered
   here.
6/16/2012                    IT Pro Camp - Jacksonville 2012           31
• Download PowerPivot at
    • http://www.powerpivot.com/download.aspx
• PowerPivot Sample Data
    • http://powerpivotsampledata.codeplex.com
• PowerPivot Tutorial Data
    • http://technet.microsoft.com/en-us/library/ee835510.aspx
• DAX On-line Function Reference
    • http://technet.microsoft.com/en-us/library/ff452127.aspx
    • http://social.technet.microsoft.com/wiki/contents/articles/powerpivot
      -dax-text-functions.aspx


6/16/2012                  IT Pro Camp - Jacksonville 2012               32
6/16/2012   IT Pro Camp - Jacksonville 2012   33
Don‟t forget to fill out your
evaluations.




Mike@micmin.org
SharePoint Book Site:
   http://sharepointmike.wordpress.com/

  6/16/2012               IT Pro Camp - Jacksonville 2012   34

More Related Content

What's hot

What's hot (9)

Excel 2007 Unit L
Excel 2007 Unit LExcel 2007 Unit L
Excel 2007 Unit L
 
Excel 2007 Unit G
Excel 2007 Unit GExcel 2007 Unit G
Excel 2007 Unit G
 
Predictive Modeling with Enterprise Miner
Predictive Modeling with Enterprise MinerPredictive Modeling with Enterprise Miner
Predictive Modeling with Enterprise Miner
 
SAS/Tableau integration
SAS/Tableau integrationSAS/Tableau integration
SAS/Tableau integration
 
11667 Bitt I 2008 Lect4
11667 Bitt I 2008 Lect411667 Bitt I 2008 Lect4
11667 Bitt I 2008 Lect4
 
Gd401 1 p autocad tables-doc
Gd401 1 p autocad tables-docGd401 1 p autocad tables-doc
Gd401 1 p autocad tables-doc
 
Sql server lesson6
Sql server lesson6Sql server lesson6
Sql server lesson6
 
Introduction to sas
Introduction to sasIntroduction to sas
Introduction to sas
 
MSBI and Data WareHouse techniques by Quontra
MSBI and Data WareHouse techniques by Quontra MSBI and Data WareHouse techniques by Quontra
MSBI and Data WareHouse techniques by Quontra
 

Similar to Hello my name is DAX

Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
Chris Seebacher
 

Similar to Hello my name is DAX (20)

Do You Have the Time
Do You Have the TimeDo You Have the Time
Do You Have the Time
 
Performance Tuning Oracle's BI Applications
Performance Tuning Oracle's BI ApplicationsPerformance Tuning Oracle's BI Applications
Performance Tuning Oracle's BI Applications
 
Ca 10 G1 John Buickerood Portfolio
Ca 10 G1 John Buickerood PortfolioCa 10 G1 John Buickerood Portfolio
Ca 10 G1 John Buickerood Portfolio
 
With big data comes big responsibility
With big data comes big responsibilityWith big data comes big responsibility
With big data comes big responsibility
 
BI Knowledge Sharing Session 2
BI Knowledge Sharing Session 2BI Knowledge Sharing Session 2
BI Knowledge Sharing Session 2
 
Elementary Data Analysis with MS excel_Day-1
Elementary Data Analysis with MS excel_Day-1Elementary Data Analysis with MS excel_Day-1
Elementary Data Analysis with MS excel_Day-1
 
Basics of Microsoft Business Intelligence and Data Integration Techniques
Basics of Microsoft Business Intelligence and Data Integration TechniquesBasics of Microsoft Business Intelligence and Data Integration Techniques
Basics of Microsoft Business Intelligence and Data Integration Techniques
 
INTRODUCTION TO SAS
INTRODUCTION TO SASINTRODUCTION TO SAS
INTRODUCTION TO SAS
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
 
Bi Portfolio
Bi PortfolioBi Portfolio
Bi Portfolio
 
Windowing functions session for Slovak SQL Pass & BI
Windowing functions session for Slovak SQL Pass & BIWindowing functions session for Slovak SQL Pass & BI
Windowing functions session for Slovak SQL Pass & BI
 
DAX (Data Analysis eXpressions) from Zero to Hero
DAX (Data Analysis eXpressions) from Zero to HeroDAX (Data Analysis eXpressions) from Zero to Hero
DAX (Data Analysis eXpressions) from Zero to Hero
 
[DSC Europe 22] Smart approach in development and deployment process for vari...
[DSC Europe 22] Smart approach in development and deployment process for vari...[DSC Europe 22] Smart approach in development and deployment process for vari...
[DSC Europe 22] Smart approach in development and deployment process for vari...
 
U-SQL Query Execution and Performance Tuning
U-SQL Query Execution and Performance TuningU-SQL Query Execution and Performance Tuning
U-SQL Query Execution and Performance Tuning
 
Getting power bi
Getting power biGetting power bi
Getting power bi
 
Intro to SQL for Beginners
Intro to SQL for BeginnersIntro to SQL for Beginners
Intro to SQL for Beginners
 
Week 03.pdf
Week 03.pdfWeek 03.pdf
Week 03.pdf
 
unit01-Activity-SQL-Query-Review-1.pptx
unit01-Activity-SQL-Query-Review-1.pptxunit01-Activity-SQL-Query-Review-1.pptx
unit01-Activity-SQL-Query-Review-1.pptx
 
Mondrian - Geo Mondrian
Mondrian - Geo MondrianMondrian - Geo Mondrian
Mondrian - Geo Mondrian
 
Kevin Fahy Bi Portfolio
Kevin Fahy   Bi PortfolioKevin Fahy   Bi Portfolio
Kevin Fahy Bi Portfolio
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

Hello my name is DAX

  • 1. Michael P. Antonovich Blog: http://SharePointMike.WordPress.com IT PRO Camp - Jacksonville 2012
  • 2. User‟s Guide to the Apple ][ - 1983 • FoxPro 2 Programming Guide – 1992 • Debugging and Maintaining FoxPro – 1992 • Using Visual FoxPro 3.0 – 1995 • Using Visual FoxPro 5.0 – 1996 • Office and SharePoint User’s Guide – 2007 • Office and SharePoint User’s Guide – 2010 Speaker at: Code Camp 2009, 2010, 2011, 2012 Orlando SharePoint Saturday 2011 Tampa, 2012 Orlando SQL Saturday - #1, #4, #8, #10, #15, #16, #21, #32, #38, #49, #62, #74, #79, #85, #86, #110, #130 6/16/2012 IT Pro Camp - Jacksonville 2012 2
  • 3. • DAX stands for: Data Analysis Expressions • DAX is used in PowerPivot to: • Create calculated columns • Create custom measures 6/16/2012 IT Pro Camp - Jacksonville 2012 3
  • 4. • Aggregate – A mathematical function that allows you to summarize values of an attribute • Dimension - A dimension is essentially a look-up table that may define a hierarchy or drill-down path such as Year > Quarter > Month • Measure – A measure is something that identifies a value • Fact – A fact is another term for a measure that contains numeric data that can be grouped along one or more dimensional hierarchy • Star Schema – All dimension tables radiate out from a single fact table • Snowflake Schema – One fact table may relate to another fact table before relating to dimension tables. One dimension table can also have a related dimension table • A Pivot table or chart is usually based around a single fact table 6/16/2012 IT Pro Camp - Jacksonville 2012 4
  • 5. PowerPivot is a data analysis tool • PowerPivot is a free download from Microsoft • PowerPivot lets you process millions of rows of data • PowerPivot uses as much memory as available & multi-cores • PowerPivot lets you integrate data from multiple sources • PowerPivot lets you explore, analyze and create analysis • PowerPivot was originally called: Project „Gemini‟ 6/16/2012 IT Pro Camp - Jacksonville 2012 5
  • 6. 32-or 64 bit Operating System • 1 GB of RAM, 2 GB recommended (or more) • Windows XP with SP3, Vista with SP1, Windows 7 • .NET Framework 3.5 SP1 or better • Microsoft Office 2010 6/16/2012 IT Pro Camp - Jacksonville 2012 6
  • 7. • Fewer data requests since staff can slice and dice their own data • More control over data other people can access • Users can generate their own reports • PowerPivot gives SQL Server data access to the masses 6/16/2012 IT Pro Camp - Jacksonville 2012 7
  • 8. • Simple Calculations • Calculated columns within fact tables • Calculated columns for dimension tables • Calculated columns between tables • Calculated columns to serve as links to tables using multiple columns (Calculated columns are calculated for every row in the table) • Aggregate Calculations • Calculate unique measures (Aggregate measures are only calculated for the displayed data in the Pivot table) 6/16/2012 IT Pro Camp - Jacksonville 2012 8
  • 9. • Comprised of 135 functions • 71 functions are similar to Excel functions • 69 have the same name – 2 do not • TEXT  FORMAT • DATEDIF  YEARFRAC • 64 functions are unique to DAX • Aggregate data functions • Date related functions 6/16/2012 IT Pro Camp - Jacksonville 2012 9
  • 10. • DAX expressions always begin with an equal sign: = • Column References can be qualified or unqualified • TableName[ColumnName] • [ColumnName] 6/16/2012 IT Pro Camp - Jacksonville 2012 10
  • 11. 6/16/2012 IT Pro Camp - Jacksonville 2012 11
  • 12. • To concatenate first and last name: = Table1[First_Name] & “-” & Table2[Last_Name] • To calculate a new measure value like Total_Profit = Table1[Total_Revenue] – Table1[Total Cost] – Table1[Returns] 6/16/2012 IT Pro Camp - Jacksonville 2012 12
  • 13. 6/16/2012 IT Pro Camp - Jacksonville 2012 13
  • 14. 6/16/2012 IT Pro Camp - Jacksonville 2012 14
  • 15. • Wrong way = DimProduct(Unit_Price) – DimProduct(Unit_Cost) • Right way = RELATED(DimProduct(Unit_Price)) – RELATED(DimProduct(Unit_Cost)) 6/16/2012 IT Pro Camp - Jacksonville 2012 15
  • 16. 6/16/2012 IT Pro Camp - Jacksonville 2012 16
  • 17. 6/16/2012 IT Pro Camp - Jacksonville 2012 17
  • 18. • Often you will need to build a Date Dimension table based on the minimum and maximum dates in your fact table. • Date Dimension tables are relatively easy to build using DAX formulas. Or you can build them in SQL Server using T-SQL. You can even build the table in Excel and use standard Excel functions. 6/16/2012 IT Pro Camp - Jacksonville 2012 18
  • 19. =DATE(<year>, <month>, <day>) =DATEVALUE(<date_text>) =DAY(<date>) =EDATE(<start_date>, <months>) =EOMONTH(<start_date>, <months>) =HOUR(<datetime>) =MINUTE(<datetime>) =MONTH(<datetime>) =NOW() =SECOND(<datetime>) =TIME(<hour>, <minute>, <second>) =TIMEVALUE(<time_text>) =TODAY() =WEEKDAY(<datetime>) =WEEKNUM(<date>, <return_type>) =YEAR(<date>) =YEARFRAC(<start_date>, <end_date>, <basis>) 6/16/2012 IT Pro Camp - Jacksonville 2012 19
  • 20. • Get the Year: =YEAR(Patient_Vaccinations[VisitDate]) • Get Month Number: =FORMAT(MONTH(Patient_Vaccinations[VisitDate]),"00" ) =FORMAT(Patient_Vaccinations[VisitDate],”MM”) • Get name of the month =FORMAT(Patient_Vaccinations[VisitDate],"MMM") • Get name of the week day =FORMAT(WEEKDAY(Patient_Vaccinations[VisitDate]), "dddd") 6/16/2012 IT Pro Camp - Jacksonville 2012 20
  • 21. • Calculating Quarter of Year =INT((MONTH(Patient_Vaccinations[VisitDate])- 1)/3)+1 • Calculating Quarter of Year Name ="Qtr " & INT((MONTH(Patient_Vaccinations[VisitDate])- 1)/3)+1 • Get week number of year =WEEKNUM(Patient_Vaccinations[VisitDate]) 6/16/2012 IT Pro Camp - Jacksonville 2012 21
  • 22. 6/16/2012 IT Pro Camp - Jacksonville 2012 22
  • 23. • Problem: • PowerPivot can only link two tables based on a single column. • You need to link two tables using two or more columns. • Solution: • Use DAX to create a calculated column that combines the data from the two columns in each table. • Typically when combining the data from multiple columns, it implies first a conversion of the column data to strings and then the string versions of the column data are the concatenated. 6/16/2012 IT Pro Camp - Jacksonville 2012 23
  • 24. 6/16/2012 IT Pro Camp - Jacksonville 2012 24
  • 25. • Standard measures are aggregated using one of the following aggregate functions: • COUNTA (count non-empty cells) • SUM • MIN • MAX • AVERAGE Note: List says COUNT, not COUNTA but it uses the COUNTA function 6/16/2012 IT Pro Camp - Jacksonville 2012 25
  • 26. • When you right click a measure, you can select from one of the following calculation types: • % of Grand Total • % of Column Total • % of Row Total • % of … • % of Parent Row Total • % of Parent Column Total • % of Parent Total … • Difference from … • % Difference from … • Running Total In … • Rank Smallest to Largest … • Rank Largest to Smallest … 6/16/2012 IT Pro Camp - Jacksonville 2012 26
  • 27. % of Parent Row % of Grand Total 6/16/2012 IT Pro Camp - Jacksonville 2012 27
  • 28. • Sometimes you need a DAX measure that is not built-in. For example, suppose you want to display the number of distinct values as a function of other dimensions, not a total count. 6/16/2012 IT Pro Camp - Jacksonville 2012 28
  • 29. 6/16/2012 IT Pro Camp - Jacksonville 2012 29
  • 30. • COUNT – Number of cells that contain numbers • COUNTA – Number of cells that contain numbers or blanks • COUNTBLANK – Counts blank cells in a column • AVERAGEA – Average based on all non-empty cells • MAXA – Largest value in column including blanks and logical values • MINA - Smallest value in column including blanks and logical values • CALCULATE – Overrides existing pivot table filters • FILTER – Applies against existing pivot table filters 6/16/2012 IT Pro Camp - Jacksonville 2012 30
  • 31. • DAX expressions are calculated independently for every cell, even total rows and total columns • One DAX expression can include another embedded DAX expression. (average profit per visit) = SUM(FactSales[TotalProfit]) / FactSales[DistinctSales] By default, DAX expressions obey filters. Sometime you need to ignore filters as in: (This is the same as % of Total) =SUM(FactSales[TotalProfit])/ CALCULATE(SUM(FactSales[TotalProfit]),ALL(FactSales)) • There are 35 time intelligence functions not covered here. 6/16/2012 IT Pro Camp - Jacksonville 2012 31
  • 32. • Download PowerPivot at • http://www.powerpivot.com/download.aspx • PowerPivot Sample Data • http://powerpivotsampledata.codeplex.com • PowerPivot Tutorial Data • http://technet.microsoft.com/en-us/library/ee835510.aspx • DAX On-line Function Reference • http://technet.microsoft.com/en-us/library/ff452127.aspx • http://social.technet.microsoft.com/wiki/contents/articles/powerpivot -dax-text-functions.aspx 6/16/2012 IT Pro Camp - Jacksonville 2012 32
  • 33. 6/16/2012 IT Pro Camp - Jacksonville 2012 33
  • 34. Don‟t forget to fill out your evaluations. Mike@micmin.org SharePoint Book Site: http://sharepointmike.wordpress.com/ 6/16/2012 IT Pro Camp - Jacksonville 2012 34

Editor's Notes

  1. C:SQLSaturday/DAX/Contoso/Contoso Data From SQL Server.xlsx=FactSales[SalesAmount] – FactSales[TotalCost] – FactSales[ReturnAmount]
  2. C:SQLSaturday/DAX/Contoso/Contoso Data From SQL Server.xlsx=(Related(DimProduct[UnitPrice]) – Related(DimProduct[UnitCost])) * FactSales[SalesQuantity]
  3. Load: C:SQLSaturday/DAX/Vaccinations2Time
  4. C:SQLSaturday/DAX/Vaccinations2Time
  5. Load: C:SQLSaturday/DAX/NCAA/NCAA_MultiColumn_Link
  6. C:SQLSaturday/DAX/NCAA/NCAA_MultiColumn_Link= [@[Institution_ID]] &amp; &quot;-&quot; &amp; [@[Uniform_Number]] &amp; &quot;-&quot; &amp; [@[Last_Name]] &amp; &quot;-&quot; &amp; [@[First_Name]]
  7. Reload C:SQLSaturday/DAX/Vaccinations2Time if necessary at this point
  8. C:SQLSaturday/DAX/Vaccinations2Time=COUNTROWS(DISTINCT(Patient_Vaccinations[VisitID]))
  9. C:SQLSaturday/DAX/Contoso/Contoso Data From SQL Server.xlsx