10 DAX Calculation For Tabular or PowerPivot Model

Slides:



Advertisements
Similar presentations
Building a Time Dimension Copyright © 2001 by Michael A. Mina.
Advertisements

17-20 OCTOBER 2011 DURBAN ICC. Killer Real-World PowerPivot Examples Kevin Coetzee Online Systems Manager Dimension Data.
Ch. 17 The Expected Value & Standard Error Review of box models 1.Pigs – suppose there is a 40% chance of getting a “trotter”. Toss a pig 20 times. –What.
Ch. 17 The Expected Value & Standard Error Review box models –Examples 1.Pigs – assume 40% chance of getting a “trotter” -20 tosses 2.Coin toss – 20 times.
DAX uses a syntax similar to Excel TableX [ColY] or [ColY] (fully qualified vs. not qualified) Cells cannot be referenced (like B23, B12:C15, …)
Implementing Common Business Calculations in DAX
Valuation of inventories. 2) For the same case, use the method of weighted arithmetical average with the continuously counted price.
Introduction to Solving Business Problems with MDX Robert Zare and Tom Conlon Program Managers Microsoft.
프로그래밍 기초와 실습 Chapter 7 Enumeration Types and typedef.
Term Project Detail Design 2 Traffic Generator So Jung LEE Dpnm Lab. CSE POSTECH
Copyright Networking Laboratory C programming and Data Structures Overview T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to Algorithms,
Solving Business Problems In OLAP Services Using MDX – Part I Amir Netz – Dev Manager & Architect Ariel Netz – Program Manager SQL Server OLAP Services.
MDX in SQL Server 2008 Szymon Wilk (na podstawie materiałów przygotowanych przez Krzysztofa Dembczyńskiego) TWO, 2009/10.
백록선.  트위터에 친숙한 36~45 세의 55 명의 응답자 ◦ 응답자 중 83% 는 매일 twit 을 읽음 ◦ 응답자 중 59% 는 매일 twit 을 씀 ◦ 응답자 중 87% 는 매일 twitter post 를 검색.
© 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5/e Starting Out with C++: Early Objects 5 th Edition Chapter 2 C++
Reports 5.02 Understand database queries, forms, and reports used in business.
INVENTORY CASE STUDY. Introduction Optimized inventory levels in stores can have a major impact on chain profitability: minimize out-of-stocks reduce.
Numbers Percentage of a number.
1 Relational Database Implementation of a Multi- dimensional database 컴퓨터언어연구실 석사 3 학기 김혜진 U.S. Patent Number: 5,926,818 Date of Patent: Jul.20,1999 inventor:
Basic Model: Retail Grocery Store
CAMDA competition 두 번째 데이터 - Class Prediction and Discovery Using Gene Expression Data 데이터 설명 및 분석.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 실 습실 습 3.
프로그래밍 기초와 실습 Chapter 6 The Fundamental Data Types.
Highline Class, BI 348 Basic Business Analytics using Excel Introduction to PowerPivot 1.
Chapter 18 Determining Sales Forecasts. Main Ideas  Importance of Forecasting Sales  Sales History  Maintaining Sales Histories  Sales Variances 
Sales Dim Date Dim Customers Dim Products Dim Categories Dim Geography The data warehouse is a simple and standard one, after all we.
전자파 연구실 ELECTROMAGNETIC MTMs 세미나 자료 4.2.1~4.3.4 발표자 : 이동현 1.
SQL Server Analysis Services 2012 BI Semantic Model BISM.
Data Cube: A Relational Aggregation Operator Generalizing Group-By, Cross-Tab, and Sub-Totals 데이터베이스 연구실 김호숙
1 M04- Graphical Displays 2  Department of ISM, University of Alabama, 2003 Graphical Displays of Data.
Find the amount after 7 years if $100 is invested at an interest rate of 13% per year if it is a. compounded annually b. compounded quarterly.
Go by Example Closures ~ Errors , Sam Jo.
9-4 The Shifter  Shifter shifts the value on Bus B  Right shift and Left shift Bidirectional shift register with parallel load First clock pulse 에 Bus.
What’s The Deal? Remember- to find the unit rate, you must compare the price using one as the denominator.
Percent Change Unit 6 Math 7.
BI Semantic Model – SSAS Tabular Mode Traditional IT focused OLAP solutions.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 실 습실 습 4.
병렬분산컴퓨팅연구실 1 Cubing Algorithms, Storage Estimation, and Storage and Processing Alternatives for OLAP 병렬 분산 컴퓨팅 연구실 석사 1 학기 이 은 정
1/24 E-Architecture 팀 e-Architecture DBA Part SQL Statement Tuning 실무사례 작성자 버전 최종 작성일 문서 번호 : 김 혜 란 : v1.1 : :
Example Materials Power BI Desktop File (4/16): 6WPbWY5UTRhaHYwdDA/view?usp=sharing.
ACIS Introduction to Data Analytics & Business Intelligence Business Intelligence Logical Functions Part 2.
MIMO Simulation Tutorial
THE TIME VALUE OF MONEY “A Dollar Today is Worth More than a Dollar Tomorrow”
ABAP Performance Tuning for SAP R/3 1 ABAP Performance Tuning.
Probability & Random Variables Prof. Jae Young Choi, Ph.D. Pattern Recognition Lab., Jungwon University Department of Biomedical Engineering
Level 200 Let‘s learn DAX Tomislav Piasevoli Piasevoli analitika d.o.o.
John Tran Business Program Manager, The Suddath Companies
Building Tabular Models
Chelsea Dohemann Class will start at approximately 8:10am PowerPivot Chelsea Dohemann
Getting Started in Power BI
REGIONAL REAL ESTATE REPORT – FEBRUARY 2017
LESSON 19-1 Determining the Quantity of Merchandise Inventory
Cross UG Summit EMEA /6/2018 7:24 PM
Module 11: Introduction to DAX Module 11 Introduction to DAX
Microsoft Power BI Bootcamp
Dumps PDF Analyzing and Visualizing Data with Microsoft Power BI Preparing for Microsoft Certification Exam
Moving Averages.
Data Analysis Expressions in PowerPivot for Excel 2010
Query Functions.
Introduction to DAX Mike Davis, Consultant Architect.
Percent Change Unit 4 Math 7.
CHAPTER NINETEEN APPENDIX
Measures of location: Mean
4.6 Exponential Growth and Decay
Ratios and Proportions Vocabulary
CHAPTER NINETEEN APPENDIX
Moving Averages.
DAX: Functions and Context That’s What It’s All About!
Presentation transcript:

10 DAX Calculation For Tabular or PowerPivot Model 2015.11.06 잘레시아 김지원

목차 1. DAX Rolling Sum and Average Calculations 2. DAX First Day of Period Calculations 3. DAX Previous Period Calculations 4. DAX Semi-Additives Measures Calculations 5. DAX Use Relationships in a Calculation 7. DAX Year Over Year Growth Calculation 6. DAX YOY Percent Growth Calculation 8. DAX Previous QTD and MTD Calculation 10. DAX YTD, QTD and MTD calculations 9. DAX Previous YTD, Year QTD, Year MTD Calculation

1. DAX Rolling Sum and Average Calculations 조회일로부터 n일 사이의 총 합계(Rolling 90 Day Total Sales Amount)와 그의 평균(Rolling 90 Day Average Sales Amount)을 구하는 DAX 계산식 Rolling 90 Day Total Sales Amount : = CALCULATE( [Total Sales Amount] , DATESBETWEEN( 'Date'[Datekey], FIRSTDATE( DATEADD( LASTDATE( 'Date'[Datekey] ),-89,Day )), LASTDATE('Date'[Datekey]) )

1. DAX Rolling Sum and Average Calculations 평균(Rolling 90 Day Average Sales Amount)을 구하기 위해 90일 동안 값이 있는 Row 개수(Day Count)를 확인 Day Count: = COUNTX( DATESBETWEEN( 'Date'[Datekey] , FIRSTDATE( DATEADD( LASTDATE('Date'[Datekey]) ,-89,Day )), LASTDATE('Date'[Datekey]) ) , [Total Sales Amount]

1. DAX Rolling Sum and Average Calculations 평균(Rolling 90 Day Average Sales Amount) : = DIVIDE([Rolling 90 Day Total Sales Amount] , [Day Count] ) 결과

2. DAX First Day of Period Calculations 연초, 분기, 월초 Day Data를 구하는 DAX 계산식 Year Starting Inventory: = CALCULATE( [Starting Inventory] , STARTOFYEAR( 'Date'[Date] ) ) Quarter Starting Inventory: = CALCULATE( [Starting Inventory] , STARTOFQUARTER( 'Date'[Date] ) ) Month Starting Inventory: = CALCULATE( [Starting Inventory] , STARTOFMONTH( 'Date'[Date] ) )

2. DAX First Day of Period Calculations 결과

3. DAX Previous Period Calculations 바로 지난 년도, 분기, 월의 Data를 구하는 계산식 Previous Month Starting Inventory: = CALCULATE( [Starting Inventory] , PREVIOUSMONTH( 'Date'[Date] ) ) Previous Year Starting Inventory: = CALCULATE( [Starting Inventory] , PREVIOUSYEAR( 'Date'[Date] ) ) Previous Quarter Starting Inventory: = CALCULATE( [Starting Inventory] , PREVIOUSQUARTER( 'Date'[Date] ) )

3. DAX Previous Period Calculations 결과

4. DAX Semi-Additives Measures Calculations 계좌 잔액이나 재고같이 sum보다는 처음이나 마지막 Data을 구하는 계산식 Starting Inventory: = CALCULATE( [Sum of Inventory] , FIRSTNONBLANK( 'Date'[Datekey] , [Sum of Inventory] ) ) Closing Inventory: LASTNONBLANK( 'Date'[Datekey] , [Sum of Inventory] ) )

4. DAX Semi-Additives Measures Calculations 결과

5. DAX Use Relationships in a Calculation Power BI나 PowerPivot, Tabular 등 OLAP 위에 하나의 Data Table 중 두 개의 서로 다른 컬럼이 Lookup Table 하나의 컬럼과 관계를 만들어 각각 기준이 다른 Measure를 구하는 계산식 먼저, 두 개의 서로 다른 컬럼은 Lookup Table의 컬럼과 관계가 맺어져 있어야 USERELATIONSHIP을 사용할 수 있다. Lookup Table의 Datekey와 Data Table의 Datekey를 주관계로, Lookup Table의 Datekey와 Data Table의 ​Updatedate를 부관계로 지정한다.

5. DAX Use Relationships in a Calculation Lookup Table과 주 관계에 있던 Sales[Datekey] 컬럼을 기준이 아닌 Sales[UpdateDate] 컬럼을 사용하기 위해 다음과 같은 계산식을 사용한다. Total Quantity by Update Date: = CALCULATE( [Total Quantity] , USERELATIONSHIP( Sales[UpdateDate] , 'Date'[Datekey] ) ) 결과

7. DAX Year Over Year Growth Calculation 올 한 해 성장을 구하는 계산식 성장 여부를 알기 위해서는 현재 Data와 작년 Data를 구해야 한다. Previous Year Total Sales Amount: = CALCULATE( [Total Sales Amount] , SAMEPERIODLASTYEAR( 'Date'[Datekey] ) ) YOY Growth Total Sales Amount: =[Total Sales Amount]-[Previous Year Total Sales Amount] 결과

6. DAX YOY Percent Growth Calculation 올 한 해 성장률을 구하는 계산식 올 해 Data값을 작년 Data값으로 백분율 계산한다. [위 슬라이드 14 Measure를 참고] 방법1 - 산술 연산자 사용 YOY Percent Growth Total Sales Amount: =[YOY Growth Total Sales Amount] / [Previous Year Total Sales Amount] 이 경우 과거 Data가 없을 경우 에러값이 리턴되므로, IFERROR를 추가한다. = IFERROR( [YOY Growth Total Sales Amount]/[Previous Year Total Sales Amount], BLANK() )

6. DAX YOY Percent Growth Calculation 방법2 - DIVIDE DAX YOY Percent Growth Total Sales Amount: = DIVIDE( [YOY Growth Total Sales Amount] , [Previous Year Total Sales Amount] ) 결과

8. DAX Previous QTD and MTD Calculation 위 슬라이드 3에서 사용한 PREVIOUSQUARTER, PREVIOUSMONTH와 기본적인 개념은 비슷하나 아래의 계산식은 DATESBETWEEN을 사용하여 Day Data까지 내려가므로 좀 더 세부적인 계산식이다. Previous QTD Total Cost: = CALCULATE( [Total Cost] , DATESBETWEEN( 'Date'[Datekey] , FIRSTDATE( PREVIOUSQUARTER( 'Date'[Datekey] ) ), LASTDATE( DATEADD( 'Date'[Datekey],-1,QUARTER )) )

8. DAX Previous QTD and MTD Calculation Previous MTD Total Cost: = CALCULATE( [Total Cost] , DATESBETWEEN( 'Date'[Datekey], FIRSTDATE( PREVIOUSMONTH( 'Date'[Datekey] ) ), LASTDATE( DATEADD( 'Date'[Datekey], -1, MONTH ) ) )

10. DAX YTD, QTD and MTD Calculations 조회 날짜의 연말, 분기말, 월말 Data를 구하는 계산식 YTD Total Cost: = CALCULATE( [Total Cost] , DATESYTD( 'Date'[Datekey] ) ) QTD Total Cost: = CALCULATE( [Total Cost] , DATESQTD( 'Date'[Datekey] ) ) MTD Total Cost: = CALCULATE( [Total Cost] , DATESMTD( 'Date'[Datekey] ) )

10. DAX YTD, QTD and MTD calculations 결과

9. DAX Previous YTD, Year QTD, Year MTD Calculation 조회 날짜 작년의 연말, 분기말, 월말 Data를 구하는 계산식 위 슬라이드 10에서 SAMEPERIODLASTYEAR를 추가하면 된다. Previous YTD Total Cost: = CALCULATE( [YTD Total Cost] , SAMEPERIODLASTYEAR( 'Date'[Datekey] ) ) Previous Year QTD Total Cost: = CALCULATE( [QTD Total Cost] , SAMEPERIODLASTYEAR( 'Date'[Datekey] ) ) Previous Year MTD Total Cost: = CALCULATE( [MTD Total Cost] , SAMEPERIODLASTYEAR( 'Date'[Datekey] ) )

9. DAX Previous YTD, Year QTD, Year MTD Calculation 결과

출처 http://sqldusty.com/2015/09/01/10-dax-calculations-for-your- tabular-or-power-pivot-model-part-1/ http://sqldusty.com/2015/10/21/10-dax-calculations-for-your- tabular-or-power-pivot-model-part-2/