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
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
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
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
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
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
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
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
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
C:SQLSaturday/DAX/Contoso/Contoso Data From SQL Server.xlsx=FactSales[SalesAmount] – FactSales[TotalCost] – FactSales[ReturnAmount]
C:SQLSaturday/DAX/Contoso/Contoso Data From SQL Server.xlsx=(Related(DimProduct[UnitPrice]) – Related(DimProduct[UnitCost])) * FactSales[SalesQuantity]
C:SQLSaturday/DAX/NCAA/NCAA_MultiColumn_Link= [@[Institution_ID]] & "-" & [@[Uniform_Number]] & "-" & [@[Last_Name]] & "-" & [@[First_Name]]
Reload C:SQLSaturday/DAX/Vaccinations2Time if necessary at this point