Microsoft Power Tools for Data Analysis #10 Power BI M Code: Helper Table to Calculate MAT By Month & Product. Notes from Video:

Similar documents
Microsoft Power Tools for Data Analysis #7 Power Query 6 Types of Merges/ Joins 9 Examples Notes from Video:

"Charting the Course... MOC C: Querying Data with Transact-SQL. Course Summary

User Guide. Data Preparation R-1.0

User Guide. Data Preparation R-1.1

"Charting the Course to Your Success!" MOC D Querying Microsoft SQL Server Course Summary

Office 2016 Excel Basics 25 Video/Class Project #37 Excel Basics 25: Power Query (Get & Transform Data) to Convert Bad Data into Proper Data Set

Contents. Tutorials Section 1. About SAS Enterprise Guide ix About This Book xi Acknowledgments xiii

2. In Video #6, we used Power Query to append multiple Text Files into a single Proper Data Set:

MariaDB Crash Course. A Addison-Wesley. Ben Forta. Upper Saddle River, NJ Boston. Indianapolis. Singapore Mexico City. Cape Town Sydney.

Shawn Dorward, MVP. Getting Started with Power Query

Language. f SQL. Larry Rockoff COURSE TECHNOLOGY. Kingdom United States. Course Technology PTR. A part ofcenqaqe Learninq

The specific steps to build Wooden Crafts database are here: 1. Create New Database. i. After opening Access, click Blank Desktop Database :

"Charting the Course... MOC B Updating Your SQL Server Skills to Microsoft SQL Server 2014 Course Summary

The SQL Guide to Pervasive PSQL. Rick F. van der Lans

Shawn Dorward, MVP. Getting Started with Power Query

INTERMEDIATE SQL GOING BEYOND THE SELECT. Created by Brian Duffey

Office 2016 Excel Basics 06 Video/Class Project #18 Excel Basics 6: Customize Quick Access Toolbar (QAT) and Show New Ribbon Tabs

BTA Billing Online Support Statement File Reference Guide

Chapter 1 Readme.doc definitions you need to know 1

Contents About SAS Enterprise Guide About This Book xi Acknowledgments xiii

Table of Contents COPYRIGHTED MATERIAL. Introduction Book I: Excel Basics Chapter 1: The Excel 2013 User Experience...

Highline Excel 2016 Class 23: Introduction to Power BI Desktop to Create Data Model & Visualization

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables

COURSE SYLLABUS. Credit Hours: Contact Hours Lab Hours 4 4 As needed by student

Workbooks (File) and Worksheet Handling

MCSA BI Reporting. A Success Guide to Prepare- Analyzing and Visualizing Data with Microsoft Excel. edusum.com

SQL Queries. for. Mere Mortals. Third Edition. A Hands-On Guide to Data Manipulation in SQL. John L. Viescas Michael J. Hernandez

QMF: Query Management Facility

Intermediate Tableau Public Workshop

Querying Data with Transact SQL

Querying Data with Transact-SQL

Table of Contents: Microsoft Power Tools for Data Analysis #15 Comprehensive Introduction to Power Pivot & DAX. Notes from Video:

Contents. Excel 2013 Workbook... 1 Starting Excel The Startup Screen... 3 The Excel Screen... 4 Quick Access Toolbar...

II.1 Running a Crystal Report from Infoview

Creating Simple Report from Excel

EVALUATION ONLY. Table of Contents. iv Labyrinth Learning

SAS. Information Map Studio 3.1: Creating Your First Information Map

Access ComprehGnsiwG. Shelley Gaskin, Carolyn McLellan, and. Nancy Graviett. with Microsoft

Contents. Project One. Introduction to Microsoft Windows XP and Office Creating and Editing a Word Document. Microsoft Word 2003

IP Camera Installation Brief Manual

Oracle Database 11g: SQL Fundamentals I

COGNOS BI I) BI introduction Products Introduction Architecture Workflows

HOW TO USE THIS BOOK... V 1 GETTING STARTED... 2

Querying Data with Transact-SQL

LawBase 12 End User Training For Upgrades

Instructor : Dr. Sunnie Chung. Independent Study Spring Pentaho. 1 P a g e

ESSENTIAL LibreOffice Tutorials for Teachers

"Charting the Course... Oracle18c SQL (5 Day) Course Summary

Querying Data with Transact SQL Microsoft Official Curriculum (MOC 20761)

Querying Data with Transact-SQL

From An Introduction to SAS University Edition. Full book available for purchase here.

NCERT solution for Fractions-2

20761 Querying Data with Transact SQL

Power Query for Parsing Data

SedonaOffice Users Conference. San Francisco, CA January 21 24, Query Builders. Presented by: Matt Howe

Join (SQL) - Wikipedia, the free encyclopedia

Module 1.Introduction to Business Objects. Vasundhara Sector 14-A, Plot No , Near Vaishali Metro Station,Ghaziabad

Duration Level Technology Delivery Method Training Credits. Classroom ILT 5 Days Intermediate SQL Server

Processor : Intel Pentium D3.0 GigaHtz

Using BI Publisher with PeopleSoft Query for Report Developers

Power BI Custom Connectors Jeroen ter Heerdt

DTS PAX (Public Access)

Excel Intermediate. Click in the name column of our Range of Data. (Do not highlight the column) Click on the Data Tab in the Ribbon

Querying Data with Transact-SQL (20761)

Intellicus Enterprise Reporting and BI Platform

Course Outline. Querying Data with Transact-SQL Course 20761B: 5 days Instructor Led

Solutions for Transformations of Functions

Facilities Manager Local Device Tracking

SAFARI DOWNLOAD INSTRUCTIONS

2013 FOUNDATION MANUAL

Querying Data with Transact-SQL

After completing this course, participants will be able to:

MARYLAND HOSPITAL DATA REPOSITORY DATA COLLECTION SYSTEM

Quick Reference Card Business Objects Toolbar Design Mode

User Guide. Web Intelligence Rich Client. Business Objects 4.1

Introduction to Microsoft Access 2016

INDIAN SCHOOL SOHAR FIRST TERM EXAM ( ) INFORMATICS PRACTICES

Using the Query. Sage DacEasy 1715 North Brown Rd Lawrenceville, GA

20461: Querying Microsoft SQL Server

Drill Down. 1. Import the file sample-sales-data.xls into Microsoft Power BI, and then create a Quantity by Year stacked column chart.

Acknowledgments...iii

Querying Microsoft SQL Server (MOC 20461C)

Website Tutorial for the APG Asbestos Trust. MFR Claims Processing, Inc. 115 Pheasant Run Suite 112 Newtown, PA (215) MFRCLAIMS.

T-SQL Training: T-SQL for SQL Server for Developers

Excel for Dummies: Quick Reference

Introduction 11; Downloading and Installing PowerPivot...,...,.,.,,,.9. 2 The Promise of PowerPivot 17 ;

Routing Algorithms McGraw-Hill The McGraw-Hill Companies, Inc., 2001

Power BI Desktop Lab

Querying Microsoft SQL Server 2014

Detailed Table of Contents

Certificate Program. Introduction to Microsoft Excel 2013

SQL Data Querying and Views

AUSTIN COMMUNITY COLLEGE CONTINUING EDUCATION. INTERMEDIATE DATABASE/FILE AMANGEMENT (Access Intermediate) (12 hours) ITSW 1055 COURSE SYLLABUS

Querying Data with Transact-SQL

edmr 2.2 Walkthrough Guide

Database System Concepts

QlikView 11.2 DIRECT DISCOVERY

Infinite Device Management

Office 2016 Excel Basics 01 Video/Class Project #13 Excel Basics 1: Excel Grid, Formatting, Formulas, Cell References, Page Setup (O16-13)

Step 1: Download the Overdrive Media Console App

Transcription:

Microsoft Power Tools for Data Analysis #10 Power BI M Code: Helper Table to Calculate MAT By Month & Product Table of Contents: Notes from Video: 1. Intermediate Fact Table / Helper Table:... 1 2. Goal of our Intermediate Fact Table Calculation... 1 1) Create a Table that cross joins Month and Product and then calculates the Monthly Total and the Moving Annual Total (MAT) for 12 Months Back.... 1 4. Step 01 Query (already created in Power BI Download File)... 1 5. Step 02 Query... 2 6. Step 03 Query... 2 7. Step 04 Query... 4 8. Step 05 Query... 4 1. Intermediate Fact Table / Helper Table: 1) Intermediate Fact Table 2) Synonyms: i. Helper Table ii. Snap Shot Table iii. Intermediate Fact Table iv. Table with intermediate calculations 3) Intermediate Fact Table make intermediate calculations that might otherwise be too complicated or calculation intensive if we included them in a Mega-Formula 2. Goal of our Intermediate Fact Table Calculation: 1) Create a Table that cross joins Month and Product and then calculates the Monthly Total and the Moving Annual Total (MAT) for 12 Months Back. 2) Advantage of a Table like this is that it might eliminate a Measure in DAX that is calculation intensive. 3. We will create a multiply Query transformation with five separate queries. 4. Step 01 Query (already created in Power BI Download File): 1) We have Text Files that contain sales numbers for each year, as seen here: Page 1 of 5

2) They have been imported into Power BI Desktop using the From Folder Feature. The Sales Table looks like this: 5. Step 02 Query: 1) Goal of this query is to create a sorted, unique list of Product names that can be used in Query 03 to do a crossjoin to get a listing of all combinations of Months and Product Names. i. Reference Step 01 Query and then lookup Product Column ii. Use List. Distinct function to create a unique list of product names iii. Use Table.Sort function to sort list. 3) M Code is here: 6. Step 03 Query: 1) Goal of this query is to create a cross join (listing of all combinations) of all moths and products that we can use in Query 5 to then make the calculations of Sales Totals and MAT for each row. i. Reference Step 01 Table ii. Remove all columns except for the Date column. iii. Convert Date column to Start Of Month Dates. iv. Lookup or Extract the Min Date. v. Lookup or Extract the Max Date. vi. Create a List of all possible dates between min and max dates. vii. Convert list of dates to a table. viii. Convert Date column to Start Of Month Dates. ix. Remove Duplicates. x. Add Custom Column to bring list of product names into each row. xi. Expand Custom Column to perform crossjoin of Start Dates and Product Names. xii. Rename Columns xiii. Change Data Types. 3) M Code on Next Page: Page 2 of 5

Page 3 of 5

7. Step 04 Query: 1) Goal of Query is to calculate Monthly Sales Totals for each month and product i. Reference Step 01 Table ii. Convert Date column to Start Of Month Dates. iii. Group By Date and Product to get Monthly Sales Totals 3) M Code is here: 8. Step 05 Query: 1) Goal of Query: Create Final Intermediate Fact Table that lists all combinations of Month and Product and shows Month Sales and Monthly Annual Totals (MAT). i. Merge Query 03 & Query 04 ii. Expand to show Monthly Sales Totals for each Product iii. Replace null values with zero values iv. Add Custom Column to calculate Date that is 12 months back v. Sort based on Date and Product, so MAT calculation will be accurate vi. Use Table.Buffer to prevent sales table from changing during MAT Calculation in the next step. vii. Add Custom Column with Function that will calculate the MAT viii. Remove unwanted columns ix. Rename Columns or Create End Of Month Date. Page 4 of 5

3) M Code is here: i. Sorting in Power Query (M Code) using the Table.Sort function: If you use the drop down arrows to sort, the first column sorted will be the Major Sort (this is the opposite of the Sort Buttons in Excel). ii. The Custom Function in the below M Code is calculated for each row in the Custom Column Table. However, the Custom Function uses two tables for each row in the Custom Column Table: 1) the Inner Table (BufferedTable in first argument of Table.SelectRows function) and 2) the Outer Table (the BufferedTable which gets the Custom Column added to it). To prevent the Inner Table from making a call for each row in the Outer Table, we can use the Table.Buffer Function to Buffer the Internal Table to prevent a call to the source table for every row in the table. Page 5 of 5