SlideShare una empresa de Scribd logo
1 de 26
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                          Orlando Code Camp 2012                               2
• 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                Orlando Code Camp 2012                3
• Database must either be in a Star or Snowflake model.
  This often means de-normalizing some tables or
  ‘flattening’ the data model. Essentially you need a central
  ‘fact’ table from which all supporting dimension data
  radiates.
• You must flatten many-to-many relationships into a single
  table with only the data that you need.
• Based on date data in your central fact table, build a date
  dimension table with the columns needed.
• Create a script to populate the date dimension table with
  data.

6/16/2012              Orlando Code Camp 2012               4
6/16/2012   Orlando Code Camp 2012   5
-- Build the Patient_Vaccinations Table
-- This will create a table of 3,462,140 rows
   SELECT
PV.VisitID, PV.CountyID, PV.VisitDate, PV.RaceID,

PV.LeadScreening, PV.PatientAge, PV.TargetedCaseMg
mt,
          PV.THStepsMed, V.Vaccination, V.VCost
      INTO Patient_Vaccinations
      FROM PatientVisits PV
      JOIN Visits_Vaccinations VV ON PV.VisitID =
VV.VisitID
      JOIN Vaccinations Orlando Code Camp 2012
6/16/2012
                        V ON VV.VaccinationID =    6
V.VaccinationID
6/16/2012   Orlando Code Camp 2012   7
• You need to calculate the date range needed for your date dimension.
  I usually look for the earliest and latest dates in the fact table and
  round the dates to January 1st for the earliest date and December 31st
  for the latest date.

• DECLARE @Min_Date DATE;
• DECLARE @Max_Date DATE;

• -- Get the smallest and largest date for start and end of date table
• SET @Min_Date = (SELECT
  CONVERT(DATE,'01/01/'+STR(YEAR(MIN(VisitDate)))) FROM
  dbo.PatientVisits);
• SET @Max_Date = (SELECT
  CONVERT(DATE,'12/31/'+STR(YEAR(MAX(VisitDate)))) FROM
  dbo.PatientVisits);

6/16/2012                   Orlando Code Camp 2012                       8
•   DECLARE @SQLSTR varchar(8000);

•   --Delete Date Dimension table if it exists
•   SET @SQLSTR = 'IF OBJECT_ID(''' + @tblname + ''', ''U'') IS NOT NULL
•     DROP TABLE ' + @tblname
•   EXECUTE(@SQLSTR)

•   --Create Date Dimension table
•   SET @SQLSTR = 'CREATE TABLE ' + @tblname +
•      ' ([PK_Date] [datetime] NOT NULL,
•                 [Date_Name] [nvarchar](50) NULL,
•                 [Year] [char](4) NULL,
•                 [Calendar_Year] [char](13) NULL,
•                 [Quarter_Of_Year] [char](1) NULL,
•                 [Quarter_Of_Year_Name] [char](9) NULL,
•                 [Year_Qtr] [char](6) NULL,
•                 [Year_Qtr_Name] [char](15) NULL,
•                 [Month] [char](2) NULL,
•                 [Month_Name] [char](15) NULL,
•                 [Year_Month] [char](10) NULL,
•                 [Year_Month_Name] [char](20) NULL,
•                 [Day_Of_Year] [char](3) NULL,
•                 [Day_Of_Year_Name] [char](8) NULL,
•                 [Day_Of_Month] [int] NULL,
•                 [Week_Of_Year] [char](2) NULL,
•                 [Week_Of_Year_Name] [char](7) NULL,
•    CONSTRAINT [PK_Time] PRIMARY KEY CLUSTERED
•   (
•                 [PK_Date] ASC
•   )WITH (PAD_INDEX = OFF,
•         STATISTICS_NORECOMPUTE = OFF,
•         IGNORE_DUP_KEY = OFF,
•         ALLOW_ROW_LOCKS = ON,
•         ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
•   ) ON [PRIMARY]'
•   EXEC(@SQLSTR)




6/16/2012                                                      Orlando Code Camp 2012   9
SET @Loop_Date = @Min_Date;

WHILE @Loop_Date <= @Max_Date
 BEGIN
  SET @SQLSTR = 'INSERT INTO ' + @tblname + ' VALUES ('''

    SET @SQLSTR = @SQLSTR + CAST(@Loop_Date as varchar(30)) + ''', '''
    SET @SQLSTR = @SQLSTR + DateName(dw,@Loop_Date) + ', ' + DateName(m,@Loop_Date) + ' ' + RTRIM('0'+CAST(DatePart(d,@Loop_Date) AS char(2)))
+ ' ' + CAST(DatePart(yyyy,@Loop_Date) as char(4)) + ''', '''
    SET @SQLSTR = @SQLSTR + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + ''', '''
    SET @SQLSTR = @SQLSTR + 'Calendar ' + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + ''', ''‘
    SET @SQLSTR = @SQLSTR + CAST(DATEPART(q,@Loop_Date) as CHAR(1)) + ''', '''
    SET @SQLSTR = @SQLSTR + 'Quarter ' + CAST(DATEPART(q,@Loop_Date) AS CHAR(1)) + ''', '''
    SET @SQLSTR = @SQLSTR + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + '-' + CAST(DATEPART(q,@Loop_Date) AS CHAR(1)) + ''', '''
    SET @SQLSTR = @SQLSTR + 'Quarter ' + CAST(DATEPART(q,@Loop_Date) AS CHAR(1)) + ', ' + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + ''', '''
    SET @SQLSTR = @SQLSTR + RIGHT('0'+RTRIM(CAST(DATEPART(m,@Loop_Date) As char(2))),2) + ''', '''
    SET @SQLSTR = @SQLSTR + DATENAME(m,@Loop_Date) + ''', '''
    SET @SQLSTR = @SQLSTR + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + '-' + RIGHT('0'+RTRIM(CAST(DATEPART(m,@Loop_Date) As
char(2))),2) + '-01' + ''', '''
    SET @SQLSTR = @SQLSTR + DATENAME(m,@Loop_Date) + ' ' + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + ''', '''
    SET @SQLSTR = @SQLSTR + RIGHT('00'+RTRIM(CAST(DATEPART(DayOfYear,@Loop_Date) AS char(3))),3) + ''', '''
    SET @SQLSTR = @SQLSTR + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + '-' + RIGHT('00'+RTRIM(CAST(DATEPART(DayOfYear,@Loop_Date)
AS char(3))),3) + ''', '''
    SET @SQLSTR = @SQLSTR + RIGHT('0'+RTRIM(CAST(DATEPART(dd,@Loop_Date) AS CHAR(2))),2) + ''', '''
    SET @SQLSTR = @SQLSTR + RIGHT('0'+RTRIM(CAST(DATEPART(wk,@Loop_Date) AS char(2))),2) + ''', '''
    SET @SQLSTR = @SQLSTR + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + '-' + RIGHT('0'+RTRIM(CAST(DATEPART(Wk,@Loop_Date) AS
char(2))),2) + ''')‘

  EXECUTE(@SQLSTR)

 --Increment loop date and see if at end
   SET @Loop_Date = DATEADD(Day,1,@Loop_Date)
 END;
  6/16/2012                                             Orlando Code Camp 2012                                                            10
6/16/2012   Orlando Code Camp 2012   11
6/16/2012   Orlando Code Camp 2012   12
•   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            Orlando Code Camp 2012           13
•   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              Orlando Code Camp 2012        14
• 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           Orlando Code Camp 2012        15
• Use 1 and only 1 header row
• All data in column should be consistently
  formatted
• No blank columns
• No blank rows
• Data columns must be 100% filled with data



6/16/2012          Orlando Code Camp 2012      16
• Always load the main transaction table first
    • This forces the fields to appear at the top of the PowerPivot Field
      List.
    • PowerPivot’s relationship detection expects the main table to be
      first.



• Import lookup tables in their hierarchical order



6/16/2012                    Orlando Code Camp 2012                         17
• Simple Calculations
    •   Calculated columns within table
    •   Calculated columns between tables
    •   Calculated columns to serve as links to other tables
    •   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                      Orlando Code Camp 2012                    18
• 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                  Orlando Code Camp 2012   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                     Orlando Code Camp 2012   20
• Get the Year:
       =YEAR(Patient_Vaccinations[VisitDate])

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

• 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               Orlando Code Camp 2012             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            Orlando Code Camp 2012            22
6/16/2012   Orlando Code Camp 2012   23
• 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                    Orlando Code Camp 2012                      24
6/16/2012   Orlando Code Camp 2012   25
Don’t forget to fill out your
evaluations.




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

  6/16/2012                 Orlando Code Camp 2012   26

Más contenido relacionado

Destacado

Balanced Scorecard Intro To Basic Concepts
Balanced Scorecard   Intro To Basic ConceptsBalanced Scorecard   Intro To Basic Concepts
Balanced Scorecard Intro To Basic Conceptsngaungsan
 
An overview of strategic alliances
An overview of strategic alliancesAn overview of strategic alliances
An overview of strategic alliancesRose Kiprop
 
Balanced Scorecard Intro To Basic Concepts
Balanced Scorecard   Intro To Basic ConceptsBalanced Scorecard   Intro To Basic Concepts
Balanced Scorecard Intro To Basic Conceptsngaungsan
 
Mule esb, Mule Anypoint studio,Mule context, Message processing
Mule esb, Mule Anypoint studio,Mule context, Message processingMule esb, Mule Anypoint studio,Mule context, Message processing
Mule esb, Mule Anypoint studio,Mule context, Message processingNaresh Naidu
 
Mule esb whole_web_services
Mule esb whole_web_servicesMule esb whole_web_services
Mule esb whole_web_servicesNaresh Naidu
 
Matrix Structure Navigating &amp; Making It Work
Matrix Structure   Navigating &amp; Making It WorkMatrix Structure   Navigating &amp; Making It Work
Matrix Structure Navigating &amp; Making It Workngaungsan
 
BSC - Introduction, Architecture, Strategy Formulation Guide &amp; Templates
BSC - Introduction, Architecture, Strategy Formulation Guide &amp; TemplatesBSC - Introduction, Architecture, Strategy Formulation Guide &amp; Templates
BSC - Introduction, Architecture, Strategy Formulation Guide &amp; Templatesngaungsan
 
โครงงานกล้วยแขก
โครงงานกล้วยแขก โครงงานกล้วยแขก
โครงงานกล้วยแขก Rut' Np
 
ใบงานที่11
ใบงานที่11ใบงานที่11
ใบงานที่11Rut' Np
 
ประโยชน์ใกล้ตัวจากเรื่องกล้วยๆ
ประโยชน์ใกล้ตัวจากเรื่องกล้วยๆประโยชน์ใกล้ตัวจากเรื่องกล้วยๆ
ประโยชน์ใกล้ตัวจากเรื่องกล้วยๆRut' Np
 
ใบงานที่ 6
ใบงานที่ 6ใบงานที่ 6
ใบงานที่ 6Rut' Np
 
ใบงานที่ 7
ใบงานที่ 7ใบงานที่ 7
ใบงานที่ 7Rut' Np
 
ใบงานที่ 5 การพัฒนาเครื่องมือ
ใบงานที่ 5  การพัฒนาเครื่องมือใบงานที่ 5  การพัฒนาเครื่องมือ
ใบงานที่ 5 การพัฒนาเครื่องมือRut' Np
 

Destacado (16)

Balanced Scorecard Intro To Basic Concepts
Balanced Scorecard   Intro To Basic ConceptsBalanced Scorecard   Intro To Basic Concepts
Balanced Scorecard Intro To Basic Concepts
 
Hello my name is DAX
Hello my name is DAXHello my name is DAX
Hello my name is DAX
 
Main
MainMain
Main
 
An overview of strategic alliances
An overview of strategic alliancesAn overview of strategic alliances
An overview of strategic alliances
 
Balanced Scorecard Intro To Basic Concepts
Balanced Scorecard   Intro To Basic ConceptsBalanced Scorecard   Intro To Basic Concepts
Balanced Scorecard Intro To Basic Concepts
 
Mule esb, Mule Anypoint studio,Mule context, Message processing
Mule esb, Mule Anypoint studio,Mule context, Message processingMule esb, Mule Anypoint studio,Mule context, Message processing
Mule esb, Mule Anypoint studio,Mule context, Message processing
 
Mule esb whole_web_services
Mule esb whole_web_servicesMule esb whole_web_services
Mule esb whole_web_services
 
Matrix Structure Navigating &amp; Making It Work
Matrix Structure   Navigating &amp; Making It WorkMatrix Structure   Navigating &amp; Making It Work
Matrix Structure Navigating &amp; Making It Work
 
BSC - Introduction, Architecture, Strategy Formulation Guide &amp; Templates
BSC - Introduction, Architecture, Strategy Formulation Guide &amp; TemplatesBSC - Introduction, Architecture, Strategy Formulation Guide &amp; Templates
BSC - Introduction, Architecture, Strategy Formulation Guide &amp; Templates
 
โครงงานกล้วยแขก
โครงงานกล้วยแขก โครงงานกล้วยแขก
โครงงานกล้วยแขก
 
01 e
01 e01 e
01 e
 
ใบงานที่11
ใบงานที่11ใบงานที่11
ใบงานที่11
 
ประโยชน์ใกล้ตัวจากเรื่องกล้วยๆ
ประโยชน์ใกล้ตัวจากเรื่องกล้วยๆประโยชน์ใกล้ตัวจากเรื่องกล้วยๆ
ประโยชน์ใกล้ตัวจากเรื่องกล้วยๆ
 
ใบงานที่ 6
ใบงานที่ 6ใบงานที่ 6
ใบงานที่ 6
 
ใบงานที่ 7
ใบงานที่ 7ใบงานที่ 7
ใบงานที่ 7
 
ใบงานที่ 5 การพัฒนาเครื่องมือ
ใบงานที่ 5  การพัฒนาเครื่องมือใบงานที่ 5  การพัฒนาเครื่องมือ
ใบงานที่ 5 การพัฒนาเครื่องมือ
 

Similar a Do You Have the Time

Uncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisUncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisRed Gate Software
 
My Business Intelligence Portfolio
My Business Intelligence PortfolioMy Business Intelligence Portfolio
My Business Intelligence Portfoliolfinkel
 
Data Warehouse and Business Intelligence - Recipe 4 - Staging area - how to v...
Data Warehouse and Business Intelligence - Recipe 4 - Staging area - how to v...Data Warehouse and Business Intelligence - Recipe 4 - Staging area - how to v...
Data Warehouse and Business Intelligence - Recipe 4 - Staging area - how to v...Massimo Cenci
 
Everything That Is Really Useful in Oracle Database 12c for Application Devel...
Everything That Is Really Useful in Oracle Database 12c for Application Devel...Everything That Is Really Useful in Oracle Database 12c for Application Devel...
Everything That Is Really Useful in Oracle Database 12c for Application Devel...Lucas Jellema
 
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014Dave Stokes
 
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...Dave Stokes
 
MySQL Indexes and Histograms - RMOUG Training Days 2022
MySQL Indexes and Histograms - RMOUG Training Days 2022MySQL Indexes and Histograms - RMOUG Training Days 2022
MySQL Indexes and Histograms - RMOUG Training Days 2022Dave Stokes
 
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...Dave Stokes
 
Cassandra Community Webinar | Become a Super Modeler
Cassandra Community Webinar | Become a Super ModelerCassandra Community Webinar | Become a Super Modeler
Cassandra Community Webinar | Become a Super ModelerDataStax
 
Date dimension table - part II
Date dimension table - part IIDate dimension table - part II
Date dimension table - part IIDirk Cludts
 
[JSS2015] Nouveautés SQL Server 2016:Sécurité,Temporal & Stretch Tables
[JSS2015] Nouveautés SQL Server 2016:Sécurité,Temporal & Stretch Tables[JSS2015] Nouveautés SQL Server 2016:Sécurité,Temporal & Stretch Tables
[JSS2015] Nouveautés SQL Server 2016:Sécurité,Temporal & Stretch TablesGUSS
 
Chris Seebacher Portfolio
Chris Seebacher PortfolioChris Seebacher Portfolio
Chris Seebacher Portfolioguest3ea163
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence PortfolioChris Seebacher
 
Oracle vs. SQL Server- War of the Indices
Oracle vs. SQL Server- War of the IndicesOracle vs. SQL Server- War of the Indices
Oracle vs. SQL Server- War of the IndicesKellyn Pot'Vin-Gorman
 
Weather scraper for your data warehouse
Weather scraper for your data warehouseWeather scraper for your data warehouse
Weather scraper for your data warehouseFru Louis
 
Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...
Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...
Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...NoSQLmatters
 

Similar a Do You Have the Time (20)

Uncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisUncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony Davis
 
MariaDB Temporal Tables
MariaDB Temporal TablesMariaDB Temporal Tables
MariaDB Temporal Tables
 
My Business Intelligence Portfolio
My Business Intelligence PortfolioMy Business Intelligence Portfolio
My Business Intelligence Portfolio
 
Data Warehouse and Business Intelligence - Recipe 4 - Staging area - how to v...
Data Warehouse and Business Intelligence - Recipe 4 - Staging area - how to v...Data Warehouse and Business Intelligence - Recipe 4 - Staging area - how to v...
Data Warehouse and Business Intelligence - Recipe 4 - Staging area - how to v...
 
Everything That Is Really Useful in Oracle Database 12c for Application Devel...
Everything That Is Really Useful in Oracle Database 12c for Application Devel...Everything That Is Really Useful in Oracle Database 12c for Application Devel...
Everything That Is Really Useful in Oracle Database 12c for Application Devel...
 
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
 
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
 
MySQL Indexes and Histograms - RMOUG Training Days 2022
MySQL Indexes and Histograms - RMOUG Training Days 2022MySQL Indexes and Histograms - RMOUG Training Days 2022
MySQL Indexes and Histograms - RMOUG Training Days 2022
 
SQL Windowing
SQL WindowingSQL Windowing
SQL Windowing
 
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
 
Cassandra Community Webinar | Become a Super Modeler
Cassandra Community Webinar | Become a Super ModelerCassandra Community Webinar | Become a Super Modeler
Cassandra Community Webinar | Become a Super Modeler
 
Date dimension table - part II
Date dimension table - part IIDate dimension table - part II
Date dimension table - part II
 
[JSS2015] Nouveautés SQL Server 2016:Sécurité,Temporal & Stretch Tables
[JSS2015] Nouveautés SQL Server 2016:Sécurité,Temporal & Stretch Tables[JSS2015] Nouveautés SQL Server 2016:Sécurité,Temporal & Stretch Tables
[JSS2015] Nouveautés SQL Server 2016:Sécurité,Temporal & Stretch Tables
 
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
 
Rdbms day3
Rdbms day3Rdbms day3
Rdbms day3
 
Chris Seebacher Portfolio
Chris Seebacher PortfolioChris Seebacher Portfolio
Chris Seebacher Portfolio
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
 
Oracle vs. SQL Server- War of the Indices
Oracle vs. SQL Server- War of the IndicesOracle vs. SQL Server- War of the Indices
Oracle vs. SQL Server- War of the Indices
 
Weather scraper for your data warehouse
Weather scraper for your data warehouseWeather scraper for your data warehouse
Weather scraper for your data warehouse
 
Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...
Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...
Lucian Precup - Back to the Future: SQL 92 for Elasticsearch? - NoSQL matters...
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
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
 
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 Processorsdebabhi2
 
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
 
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
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Último (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
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
 
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
 
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?
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

Do You Have the Time

  • 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 Orlando Code Camp 2012 2
  • 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 Orlando Code Camp 2012 3
  • 4. • Database must either be in a Star or Snowflake model. This often means de-normalizing some tables or ‘flattening’ the data model. Essentially you need a central ‘fact’ table from which all supporting dimension data radiates. • You must flatten many-to-many relationships into a single table with only the data that you need. • Based on date data in your central fact table, build a date dimension table with the columns needed. • Create a script to populate the date dimension table with data. 6/16/2012 Orlando Code Camp 2012 4
  • 5. 6/16/2012 Orlando Code Camp 2012 5
  • 6. -- Build the Patient_Vaccinations Table -- This will create a table of 3,462,140 rows SELECT PV.VisitID, PV.CountyID, PV.VisitDate, PV.RaceID, PV.LeadScreening, PV.PatientAge, PV.TargetedCaseMg mt, PV.THStepsMed, V.Vaccination, V.VCost INTO Patient_Vaccinations FROM PatientVisits PV JOIN Visits_Vaccinations VV ON PV.VisitID = VV.VisitID JOIN Vaccinations Orlando Code Camp 2012 6/16/2012 V ON VV.VaccinationID = 6 V.VaccinationID
  • 7. 6/16/2012 Orlando Code Camp 2012 7
  • 8. • You need to calculate the date range needed for your date dimension. I usually look for the earliest and latest dates in the fact table and round the dates to January 1st for the earliest date and December 31st for the latest date. • DECLARE @Min_Date DATE; • DECLARE @Max_Date DATE; • -- Get the smallest and largest date for start and end of date table • SET @Min_Date = (SELECT CONVERT(DATE,'01/01/'+STR(YEAR(MIN(VisitDate)))) FROM dbo.PatientVisits); • SET @Max_Date = (SELECT CONVERT(DATE,'12/31/'+STR(YEAR(MAX(VisitDate)))) FROM dbo.PatientVisits); 6/16/2012 Orlando Code Camp 2012 8
  • 9. DECLARE @SQLSTR varchar(8000); • --Delete Date Dimension table if it exists • SET @SQLSTR = 'IF OBJECT_ID(''' + @tblname + ''', ''U'') IS NOT NULL • DROP TABLE ' + @tblname • EXECUTE(@SQLSTR) • --Create Date Dimension table • SET @SQLSTR = 'CREATE TABLE ' + @tblname + • ' ([PK_Date] [datetime] NOT NULL, • [Date_Name] [nvarchar](50) NULL, • [Year] [char](4) NULL, • [Calendar_Year] [char](13) NULL, • [Quarter_Of_Year] [char](1) NULL, • [Quarter_Of_Year_Name] [char](9) NULL, • [Year_Qtr] [char](6) NULL, • [Year_Qtr_Name] [char](15) NULL, • [Month] [char](2) NULL, • [Month_Name] [char](15) NULL, • [Year_Month] [char](10) NULL, • [Year_Month_Name] [char](20) NULL, • [Day_Of_Year] [char](3) NULL, • [Day_Of_Year_Name] [char](8) NULL, • [Day_Of_Month] [int] NULL, • [Week_Of_Year] [char](2) NULL, • [Week_Of_Year_Name] [char](7) NULL, • CONSTRAINT [PK_Time] PRIMARY KEY CLUSTERED • ( • [PK_Date] ASC • )WITH (PAD_INDEX = OFF, • STATISTICS_NORECOMPUTE = OFF, • IGNORE_DUP_KEY = OFF, • ALLOW_ROW_LOCKS = ON, • ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] • ) ON [PRIMARY]' • EXEC(@SQLSTR) 6/16/2012 Orlando Code Camp 2012 9
  • 10. SET @Loop_Date = @Min_Date; WHILE @Loop_Date <= @Max_Date BEGIN SET @SQLSTR = 'INSERT INTO ' + @tblname + ' VALUES (''' SET @SQLSTR = @SQLSTR + CAST(@Loop_Date as varchar(30)) + ''', ''' SET @SQLSTR = @SQLSTR + DateName(dw,@Loop_Date) + ', ' + DateName(m,@Loop_Date) + ' ' + RTRIM('0'+CAST(DatePart(d,@Loop_Date) AS char(2))) + ' ' + CAST(DatePart(yyyy,@Loop_Date) as char(4)) + ''', ''' SET @SQLSTR = @SQLSTR + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + ''', ''' SET @SQLSTR = @SQLSTR + 'Calendar ' + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + ''', ''‘ SET @SQLSTR = @SQLSTR + CAST(DATEPART(q,@Loop_Date) as CHAR(1)) + ''', ''' SET @SQLSTR = @SQLSTR + 'Quarter ' + CAST(DATEPART(q,@Loop_Date) AS CHAR(1)) + ''', ''' SET @SQLSTR = @SQLSTR + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + '-' + CAST(DATEPART(q,@Loop_Date) AS CHAR(1)) + ''', ''' SET @SQLSTR = @SQLSTR + 'Quarter ' + CAST(DATEPART(q,@Loop_Date) AS CHAR(1)) + ', ' + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + ''', ''' SET @SQLSTR = @SQLSTR + RIGHT('0'+RTRIM(CAST(DATEPART(m,@Loop_Date) As char(2))),2) + ''', ''' SET @SQLSTR = @SQLSTR + DATENAME(m,@Loop_Date) + ''', ''' SET @SQLSTR = @SQLSTR + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + '-' + RIGHT('0'+RTRIM(CAST(DATEPART(m,@Loop_Date) As char(2))),2) + '-01' + ''', ''' SET @SQLSTR = @SQLSTR + DATENAME(m,@Loop_Date) + ' ' + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + ''', ''' SET @SQLSTR = @SQLSTR + RIGHT('00'+RTRIM(CAST(DATEPART(DayOfYear,@Loop_Date) AS char(3))),3) + ''', ''' SET @SQLSTR = @SQLSTR + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + '-' + RIGHT('00'+RTRIM(CAST(DATEPART(DayOfYear,@Loop_Date) AS char(3))),3) + ''', ''' SET @SQLSTR = @SQLSTR + RIGHT('0'+RTRIM(CAST(DATEPART(dd,@Loop_Date) AS CHAR(2))),2) + ''', ''' SET @SQLSTR = @SQLSTR + RIGHT('0'+RTRIM(CAST(DATEPART(wk,@Loop_Date) AS char(2))),2) + ''', ''' SET @SQLSTR = @SQLSTR + CAST(DATEPART(yyyy,@Loop_Date) AS CHAR(4)) + '-' + RIGHT('0'+RTRIM(CAST(DATEPART(Wk,@Loop_Date) AS char(2))),2) + ''')‘ EXECUTE(@SQLSTR) --Increment loop date and see if at end SET @Loop_Date = DATEADD(Day,1,@Loop_Date) END; 6/16/2012 Orlando Code Camp 2012 10
  • 11. 6/16/2012 Orlando Code Camp 2012 11
  • 12. 6/16/2012 Orlando Code Camp 2012 12
  • 13. 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 Orlando Code Camp 2012 13
  • 14. 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 Orlando Code Camp 2012 14
  • 15. • 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 Orlando Code Camp 2012 15
  • 16. • Use 1 and only 1 header row • All data in column should be consistently formatted • No blank columns • No blank rows • Data columns must be 100% filled with data 6/16/2012 Orlando Code Camp 2012 16
  • 17. • Always load the main transaction table first • This forces the fields to appear at the top of the PowerPivot Field List. • PowerPivot’s relationship detection expects the main table to be first. • Import lookup tables in their hierarchical order 6/16/2012 Orlando Code Camp 2012 17
  • 18. • Simple Calculations • Calculated columns within table • Calculated columns between tables • Calculated columns to serve as links to other tables • 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 Orlando Code Camp 2012 18
  • 19. • 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 Orlando Code Camp 2012 19
  • 20. =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 Orlando Code Camp 2012 20
  • 21. • Get the Year: =YEAR(Patient_Vaccinations[VisitDate]) • Get Month Number: =FORMAT(MONTH(Patient_Vaccinations[VisitDate]),"00" ) • 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 Orlando Code Camp 2012 21
  • 22. • 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 Orlando Code Camp 2012 22
  • 23. 6/16/2012 Orlando Code Camp 2012 23
  • 24. • 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 Orlando Code Camp 2012 24
  • 25. 6/16/2012 Orlando Code Camp 2012 25
  • 26. Don’t forget to fill out your evaluations. Mike@micmin.org SharePoint Book Site: http://sharepointmike.wordpress.com/ 6/16/2012 Orlando Code Camp 2012 26

Notas del editor

  1. Run SQL: BuildTexasData
  2. Transaction: Patient_VaccinationsDimensions:DateTableCountyDataRaceTable Regions
  3. Next we need to define the DAX formula for the measure. We learned earlier that all DAX formulas begin with an equal sign. Then as we type additional characters, the tool-tip help displays the possible commands that begin with that letter(s) along with a helpful hint about what the function returns. In this case, as we type ‘di’ for DISTINCT, we learn that this function returns a one column table in which the distinct values appear in a single column. The fact that this function returns not a column or list of values, but a table is something to remember. The reason this is important will become evident shortly. As we press the Tab key to complete the selection of this function, we see the function expects as an input parameter a column. At this point the expression builder box contains =DISTINCT(. If I type the first letter of any of the tables, the tooltip help will display a reference to all the fields in the table. To count distinct visits, I will use the VisitID field in the Patient_Vaccinatinos table as shown in the following figure.If we were to close off the equation at this point and attempt to use it in our pivot table, we would get the error message:ERROR – CALCULATION ABORTED: MdxScript(Sandbox) (8,66) A table of multiple values was supplied where a single value was expected.A measure must return a single value, not a table or even a column. Therefore, we have to wrap this calculation inside of another function that can count the rows in a table. Looking through the available DAX functions, the obvious choice is the function =COUNTROWS() which fortunately accepts a table as input. Similar functions like =COUNT() and =COUNTA() expect to have a column passed to them, not a table. Remember a column is essentially a field in one of our source tables from the PivotTable Window. (By the way, the different between =COUNT() and =COUNTA() is that….)Final Expression is: COUNTROWS(DISTINCT(Patient_Vaccinations[VisitID]))