One Page Summary Data Analytics Intermediate Module 4 30sep

2
Data Analysis Expressions (DAX) DAX Publish Reports to Power BI service Data Modeling Power BI is designed to work with common data structure called the snowflake schema. DAX stands for Data Analysis Expressions. DAX is the formula language used throughout Power BI (it's also used by Power BI behind the scenes). DAX is also known as function language, where the full code is kept inside a function. DAX programming formula contains two data types: Numeric and Other. Numeric includes - integers, currency and decimals. Other includes: string and binary object. DAX Functions In Power BI, you can use different function types to analyze data, and create new columns and measures. It includes functions from different categories such as Aggregate (MIN, MAX, Average, SUM, SUMX) Text (REPLACE, SEARCH, UPPER, FIXED, CONCATENATE) Date (DATE, HOUR, WEEKDAY, NOW, EOMONTH) Logical (AND, OR, NOT, IF, IFERROR) Counting (DISTINCTCOUNT, COUNT, COUNTA, COUNTROWS, COUNTBLANK) Information (ISBLANK, ISNUMBER, ISTEXT, ISNONTEXT, ISERROR) In Power BI, you can create two primary calculations using DAX − Calculated columns Calculated measures Power BI provides an easy way to see the list of all functions. When you start typing your function in the formula bar, you can see the list of all functions starting with that alphabet. Data Modeling is one of the features used to connect multiple data sources in BI tool using a relationship. Creating a new Table with DAX Date Table Column and Measure Ribbon Modeling -> New Table Power Query Home -> Edit Queries Merge Queries Rename table and unload Change Query name from Stores to dStore Right click on on Geography, unmark Enable load Relationship Power BI detects the relationship between the columns automatically. You can also add and remove relationships. You can also use the Relationship view to hide a particular column in the report. Star Schema From Snowflake schema to Star schema Macro Russo and Alberto Ferrari suggested that the best schema for Power BI is star schema Snowflake schema Fact table: contains events or transactions Dimension tables: what, when, where, which Creating a date table as you wish = CALENDAR(DATE(<start_year>, 1, 1), DATE(<end_year>, 12, 31)) Find a start year & end year Creating variables Finding start year from YEAR(MIN(fSales[DateKey])) Finding end year from YEAR(MAX(fSales[DateKey])) Mark as Date Table Time Intelligence functions which simply enable you to perform Business Intelligence analysis workload by manipulating data using Time, Periods like Date, Month, Quarter and Year analysis. Creating a column Year = YEAR(dDate[Date]) MonthNum = MONTH(dDate[Date]) DayNum = DAY(dDate[Date]) MonthName = FORMAT(dDate[Date],"mmmm") DayName = FORMAT(dDate[Date],"dddd") YearMonth = FORMAT(dDate[Date],"yyyymm") Creating a Quarter column Creating a Relationship (fact table and dDate) FACT TABLE DIMENSION DIMENSION DIMENSION DIMENSION FACT TABLE Dim Dim Dim Dim Dim 2021 © TRUE DIGITAL ACADEMY Data Analytics Intermediate I Module 4: Data Analytics with Power BI Data Analytics Intermediate 1 Data Analytics with Power BI (PART 2) Module 4

Transcript of One Page Summary Data Analytics Intermediate Module 4 30sep

Data Analysis Expressions (DAX)DAX

Publish Reports to Power BI service

Data ModelingPower BI is designed to work with common data structure called the snowflake schema.

DAX stands for Data Analysis Expressions.DAX is the formula language used throughout Power BI (it's also used by Power BI behind the scenes).DAX is also known as function language, where the full code is kept inside a function. DAX programming formula contains two data types: Numeric and Other. Numeric includes - integers, currency and decimals. Other includes: string and binary object.

DAX FunctionsIn Power BI, you can use different function types to analyze data, and create new columns and measures. It includes functions from different categories such as Aggregate (MIN, MAX, Average, SUM, SUMX) Text (REPLACE, SEARCH, UPPER, FIXED, CONCATENATE) Date (DATE, HOUR, WEEKDAY, NOW, EOMONTH) Logical (AND, OR, NOT, IF, IFERROR) Counting (DISTINCTCOUNT, COUNT, COUNTA, COUNTROWS, COUNTBLANK) Information (ISBLANK, ISNUMBER, ISTEXT, ISNONTEXT, ISERROR)

In Power BI, you can create two primary calculations using DAX − Calculated columns Calculated measures

Power BI provides an easy way to see the list of all functions. When you start typing your function in the formula bar, you can see the list of all functions starting with that alphabet.

Data Modeling is one of the features used to connect multiple data sources in BI tool using a relationship.

Creating a new Table with DAX

Date Table Column and Measure

Ribbon Modeling -> New Table

Power QueryHome -> Edit QueriesMerge Queries

Rename table and unloadChange Query name from Stores to dStore Right click on on Geography, unmark Enable load

RelationshipPower BI detects the relationship between the columns automatically.You can also add and remove relationships.You can also use the Relationship view to hide a particular column in the report.

Star Schema

From Snowflake schema to Star schema

Macro Russo and Alberto Ferrari suggested that the best schema for Power BI is star schema

Snowflake schemaFact table: contains events or transactionsDimension tables: what, when, where, which

Creating a date table as you wish

= CALENDAR(DATE(<start_year>, 1, 1), DATE(<end_year>, 12, 31))

Find a start year & end year

Creating variables

Finding start year from YEAR(MIN(fSales[DateKey]))Finding end year from YEAR(MAX(fSales[DateKey]))

Mark as Date TableTime Intelligence functions which simply enable you to perform Business Intelligence analysis workload by manipulating data using Time, Periods like Date, Month, Quarter and Year analysis.

Creating a column

Year = YEAR(dDate[Date])MonthNum = MONTH(dDate[Date])DayNum = DAY(dDate[Date])MonthName = FORMAT(dDate[Date],"mmmm")DayName = FORMAT(dDate[Date],"dddd")YearMonth = FORMAT(dDate[Date],"yyyymm")

Creating a Quarter column

Creating a Relationship (fact table and dDate)

FACT TABLE

DIMENSION

DIMENSION

DIMENSION

DIMENSION

FACTTABLE

Dim

Dim Dim

Dim

Dim

2021 © TRUE DIGITAL ACADEMY Data Analytics Intermediate I Module 4: Data Analytics with Power BI

Data Analytics Intermediate 1Data Analytics with Power BI (PART 2)

Module

4

DAX Table: Valued Functions

Avoid Implicit Measure

Calculate TotalRevenue

Avoid Implicit MeasureUse implicit actions as little as possible. What you want to do is to create explicit actions by creating new calculated measures.Good things about explicit measure: Number format stick with Measure Be able to write complex calculations Imported Power BI Service with Analyze in Excel

DAX Table: Valued Functions Filter Function

Year to Date Year over year change

Time Intelligence

Many DAX functions take tables as input or output tables or do both. These DAX functions are called DAX table-valued functions. You have the following types of DAX table-valued functions − DAX Aggregation functions DAX Filter functions DAX Time intelligence functions

Example: myTable = FILTER(dProduct,dProduct[UnitPrice]>200)

Example: filter and refer to another table (Related)

Example: Filter and Measure

Creating a Visual (Sales Quantity)Create a table displaying MonthName, SalesQuantity by dragging fields to Visual. This approach is called Implicit Measure.

Calculated Column vs Calculated MeasureCalculated Column: The content of the columns is defined by a DAX expression evaluated row by row.Calculated Measure: Whenever you do not want to compute values for each row but, rather, you want to aggregate values from many rows in a table.

TotalOnlineRevenue = SUMX(FILTER(fSales,RELATED(dStore[Store-Type])="Online"), fSales[SalesQuantity]*RELATED(dProduct[Unit-Price]))

DAX includes time-intelligence functions that enable you to manipulate data using time periods, including days, months, quarters, and years, then build and compare calculations over those periods.

Sort by Column

Creating a column by referring a column from another table

Creating another column

Creating a measure

SUMX function

2021 © TRUE DIGITAL ACADEMY Data Analytics Intermediate I Module 4: Data Analytics with Power BI

Data Analytics Intermediate 1Data Analytics with Power BI (PART 2)

Module

4