Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

INTERACTIVE DASHBOARDS WITH POWER BI

By Luong My Linh
AGENDA
1 POWER BI OVERVIEW

2 DATA VISUALIZATION

3 DATA MODELING

4 POWER QUERY EDITOR

5 FORMULAS IN DAX

6 CREATE A DASHBOARD
I. POWER BI OVERVIEW
I. POWER BI OVERVIEW

What is Power BI? Getting started with Power BI


Power BI is a business intelligence tool that allows you to There are three main views in Power BI
effectively report insights through easy to use customizable
visualizations and dashboards.

Why use Power BI?


Easy to use no coding Integrates seamlessly Fast and can handle
involved with any data source large datasets

Power BI Components
There are three components to Power BI each of them serving
different purposes
Power BI Desktop Power BI service Power BI mobile
Free desktop application Cloud based version of A mobile app of Power
that provides data Power BI with report BI, which allows you to
analysis and creation editing and publishing author, view, and share
tools features reports on the go
I. POWER BI OVERVIEW

Visualizing your first dataset

Upload datasets into Power BI Create your first visualization


• Home tab, Click on Get Data • Click on the Report View and go to the Visualization pane on the right hand side
• Choose any of your datasets and double click • Select the type of visualization you would like to plot your data on¸ Keep reading
• Click Load if not prior data needs processing this cheat to learn different visualizations available in Power BI
• If you need to transform the data, click Transform which will launch Power • Under the Field pane on the right hand side, drag the variables of your choice
Query. Then, click Apply transformation in Power query into Values or Axis.
• Inspect your data by clicking on the Data view

Create relationships in Power BI Aggregating data


Power BI sums numerical fields when visualizing them under Values. However, you can
Upload datasets into Power BI choose different aggregation
• Select the visualization you just created
• Go to the Visualizations section on the right hand side
• If you have different datasets you want to
• Go to Values - the visualized column should be there
connect ̧ First, upload them into Power BI
• On the selected column click on the dropdown arrow and change the aggregation
• Click on the Model View from the left-hand
(AVERAGE, MAX, COUNT, etc..)
pane
• Connect key columns from different datasets
by dragging one to another (EmployeeID to
SalespersonID)
II. DATA VISUALIZATIONS

What is Data Visualization?


• Data visualization is the visual presentation of data or information. The goal of
data visualization is to communicate data or information clearly and effectively to
readers. Typically, data is visualized in the form of a chart, infographic, diagram
or map
• The field of data visualization combines both art and data science. While a data
visualization can be creative and pleasing to look at, it should also be functional
in its visual communication of the data.

What is data visualization used for?


• Data, especially a lot of data, can be difficult to wrap your head around. Data
visualization can help both you and your audience interpret and understand data.
• Data visualizations often use elements of visual storytelling to communicate a
message supported by the data.
II. DATA VISUALIZATIONS

There are more than 40 types of charts out there


How to choose a chart type that describes your data best?
II. DATA VISUALIZATIONS

Power BI provides a wide range of data visualizations. Here is a list of the most useful visualizations
you have in Power BI
III. DATA MODELING FOR POWER BI

What is Data Modeling?


Data modelling is the process of analysing and defining all the
different data tables your business collects , as well as the
relationships between those tables.

Dimensional Modeling
Model: Star Schema (Facts and Dimensions table)

Fact table: A fact is an event that may or may not include


measures
Dim table: Category of information, or a noun, descriptive
Attribute (column in dimension table)
III. DATA MODELING FOR POWER BI

Dimenions

Dim table
A Dim (or Dimention) table contains
descriptive attributes that define how a fact
should roll up

Ex:
By Month
By Customer

III. DATA MODELING FOR POWER BI

Relationships

Relationships
Connection between 2 tables (usually fact &
dim) using columns from each

Types
1 to many | many to 1
1 to 1
Many to many

https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-create-and-manage-relationships
III. DATA MODELING FOR POWER BI

Example:

have

N N

have

1
III. DATA MODELING FOR POWER BI

Edit relation:

Delete relationship
Edit relationship

Single/Both

Choose a type relationship


One-to-many (1:*)
Many-to-one (*:1)
One-to-one (1:1)
Many-to-many (*:*)
IV. POWER QUERY EDITOR

Power Query is Microsoft’s data transformation and data preparation engine. It is part of Power BI Desktop, and lets
you connect to one or many data sources, shape and transform data to meet your needs, and load it into Power BI.
IV. POWER QUERY EDITOR

Power Query is Microsoft’s data transformation and data preparation engine. It is part of Power BI Desktop, and lets
you connect to one or many data sources, shape and transform data to meet your needs, and load it into Power BI.

Open the Power Query Editor


While loading data
• Underneath the Home tab, click on Get Data
• Choose any of your datasets and double click
• Click on Transform Data

While data is already loaded


• Home tab > Click Transform Data > Click Transform Data

Steps
Using the Power Query Editor
• Remove/Keep rows
• Choose/Remove columns Apply any
• Change the data type pending
• Add column
• Split/replace values change
• Append Queries (Kết hợp bảng theo chiều dọc)
• Merger Queries (Kết hợp bảng theo chiều ngang)
V. FORMULAS IN DAX

Data Analysis Expressions (DAX) is a library of functions and operators that can be combined to build formulas and expressions in
Power BI
AGGREGATION FUNCTIONS
These functions calculate a (scalar) value such as count, sum, average, minimum, or maximum for all rows in a column or table as defined by the expression

AVERAGE AVERAGE(<column>) Trả về giá trị trung bình (trung bình cộng) của tất cả các số trong một cột
AVERAGEA AVERAGEA(<column>) Trung bình cộng của tất cả các giá trị trong cột, nếu là chữ, null, trống thì sẽ coi là 1
Tính trung bình dựa trên 1 biểu thức trong 1 bảng
AVERAGEX AVERAGEX(<table>,<expression>) (expression trả về kết quả cho mỗi hàng của bảng)
MAX(<column>)
MAX MAX(<expression1>, <expression2>) Trả về giá trị lớn nhất trong 1 cột (bỏ qua giá trị trống) hoặc giữa 2 biểu thức
MAXA MAXA(<column>) Trả về giá trị lớn nhất trong 1 cột, bỏ qua giá trị trống. Nếu trong ô có chưa giá trị là TRUE <=> 1, FALSE <=> 0
Trả về giá trị lớn nhất trong số các kết quả thu được từ 1 biểu thức tính (expression trả về kết quả là mỗi hàng của
MAXX MAXX(<table>,<expression>) bảng).
Khi được sử dụng với một cột, hàm MAX thực thi nội bộ MAXX mà không có bất kỳ sự khác biệt nào về hiệu suất.
MIN MIN(<column>)
MIN(<expression1>, <expression2>) Trả về giá trị nhỏ nhất trong 1 cột hoặc giữa 2 biểu thức
MINA MINA(<column>) Trả về giá trị nhỏ nhất trong 1 cột, bỏ qua giá trị trống. Nếu trong ô có chưa giá trị là TRUE <=> 1, FALSE <=> 0
Trả về giá trị nhỏ nhất trong số các kết quả thu được từ 1 biểu thức tính (expression trả về kết quả là mỗi hàng của
MINX MINX(<table>,<expression>) bảng)
PRODUCT PRODUCT(<column>) Trả về tích của các số trong 1 cột (kiểu dữ liệu giữa hai cột dạng number)

PRODUCTX PRODUCTX(<table>, <expression>) Trả về tích các số mà các số này được tạo ra từ kết quả của 1 biểu thức tính, expression trả về kết quả là một cột
SUM SUM(<column>) Tính tổng của 1 cột
SUMX SUMX(<table>, <expression>) Tính tổng giá trị của expression, expression có thể là row by row hoặc có thể là 1 giá trị
V. FORMULAS IN DAX

Data Analysis Expressions (DAX) is a library of functions and operators that can be combined to build formulas and expressions in
Power BI
AGGREGATION FUNCTIONS
These functions calculate a (scalar) value such as count, sum, average, minimum, or maximum for all rows in a column or table as defined by the expression

COUNT COUNT(<column>) Đếm toàn bộ các giá trị khác trống, không đếm giá trị Boolean
Đếm toàn bộ các giá trị khác trống, không đếm giá trị Boolean
COUNTX COUNTX(<table>,<expression>)
trong 1 cột hoặc 1 biểu thức của 1 bảng
COUNTA COUNTA(<column>) Đếm toàn bộ các giá trị khác trống (bao gồm cả giá trị Boolean)
Đếm toàn bộ các giá trị khác trống (bao gồm cả giá trị Boolean)
COUNTAX COUNTAX(<table>,<expression>)
của expression, expression yêu cầu trả về là một cột
COUNTBLANK COUNTBLANK(<column>) Đếm các giá trị trống trong cột
Đếm toàn bộ các hàng trong cột, function này chủ yếu dùng kết hợp đếm với 1 điều kiện của bảng
COUNTROWS COUNTROWS([<table>])
CALCULATE(COUNTROWS(test),FILTER(test,test[col1]>5))
DISTINCTCOUNT DISTINCTCOUNT(<column>) Đếm các giá trị khác nhau trong 1 cột, đếm cả giá trị trống
DISTINCTCOUNTNO
DISTINCTCOUNTNOBLANK (<column>) Đếm các giá trị khác nhau trong 1 cột, không đếm giá trị trống
BLANK
V. FORMULAS IN DAX

Data Analysis Expressions (DAX) is a library of functions and operators that can be combined to build formulas and expressions in
Power BI
FILTER FUNCTIONS
Filtering functions let you manipulate data context to create dynamic calculations.

CALCULATE CALCULATE(<expression>[, <filter1> [, <filter2> [, …]]]) Trả về giá trị của expression theo điều kiện được chỉ định
FILTER FILTER(<table>,<filter>) Trả về 1 tập theo điều kiện được chỉ định

EX: Total unit sold = CALCULATE(SUM(Sales Data[Unit Sold]), Sales Data[Unit Sold]<50)

Hàm FILTER thường dùng kết hợp với các hàm tổng hợp SUM, COUNT, AVG,… với một hay nhiều điều kiện
Có thể dùng SUMX, COUNTX, COUNTAX, AVGX,…Thay thế cho CACULATE

EX: Total unit sold = SUMX(FILTER(Sales Data, Sales Data[Unit Sold]<50), Sales Data[Unit Sold])

RELATIONSHIP FUNCTIONS
Filtering functions let you manipulate data context to create dynamic calculations.

RELATED RELATED(<column>) Trả về một giá trị có liên quan từ một bảng khác.

EX: Revenue = SUMX('Sales Data','Sales Data'[Unit Sold]*RELATED('Product Master'[Price per unit]))


V. FORMULAS IN DAX

Data Analysis Expressions (DAX) is a library of functions and operators that can be combined to build formulas and expressions in
Power BI
DATE AND TIME FUNCTIONS
These functions in DAX are similar to date and time functions in Microsoft Excel. However, DAX functions are based on the datetime data types used by Microsoft SQL Server.

CALENDER CALENDER(<start_date>,<end_date>) Trả về 1 bảng gồm 1 cột “Date” gồm các ngày bắt đầu từ <start_date> đến <end_date>
DATE DATE(<year>,<month>,<day>) Trả về cột “Date” được cấu thành từ 3 cột year,month,day
DAY DAY(<date>) Trả về thành phần “Ngày” của cột date (1-31)
MONTH MONTH(<date>) Trả về thành phần “Tháng” của cột date (1-12)
QUARTER QUARTER(<date>) Trả về thành phần “Quý” của cột date (1-4)
YEAR YEAR(<date>) Trả về thành phần “Năm” của cột date
WEEKNUM WEEKNUM(<date>) Trả về tuần trong năm của date (1-52)
Trả về thứ trong tuần của date (1-7)
WEEKDAY WEEKDAY(<date>)

DATEDIFF DATEDIFF(<date_1>,<date_2>,<interval>) Trả về khoảng cách giữa 2 ngày theo interval (ngày/tháng/năm…)
DATEADD DATEADD(<date>,<number_of_intervals>,<interval>) Cộng thêm 1 1 khoảng thời gian vào cột date
DATEVALUE DATEVALUE(<date_text>) Chuyển đổi kiểu dữ liệu cột date đang có định dạng text sang định dạng datetime
FORMAT FORMAT(<date>, <format_string>)
V. FORMULAS IN DAX

FORMAT (detail)

Format Result (en-US) Format Result (en-US)


"c" 06/25/2020 13:23:45 "y" 177
"d" 25 "yy" 20
"dd" 25 "yyyy \Qq" 2020 Q2
"ddd" Thu "dd/mm/yyyy" 25/06/2020
"dddd" Thursday "mm/dd/yyyy" 06/25/2020
"ddddd" 06/25/2020 "h:nn:ss" 13:23:45
"dddddd" Thursday, June 25, 2020 "h:nn:ss AMPM" 1:23:45 PM
"w" 5 "hh:nn:ss" 13:23:45
"ww" 26 "hh:nn:ss AMPM" 01:23:45 PM
"m" 6 "ttttt" 13:23:45

"mm" 06 "ttttt AMPM" 13:23:45 PM


"mmm" Jun "mm/dd/yyyy hh:nn:ss AMPM" 06/25/2020 01:23:45 PM

"q" 2
V. FORMULAS IN DAX

Data Analysis Expressions (DAX) is a library of functions and operators that can be combined to build formulas and expressions in
Power BI
TEXT FUNCTIONS

LEFT LEFT(<text>, <num_chars>)


RIGHT RIGHT(<text>, <num_chars>)
MID MID(<text>, <start_num>, <num_chars>)
LEN LEN(<text>)
LOWER LOWER (<text>)
UPPER UPPER (<text>)
TRIM TRIM(<text>)
CONCATENATE CONCATENATE(<text1>, <text2>)
CONCATENATEX CONCATENATEX(<table>, <expression>[, <delimiter> ]) CONCATENATEX(Employees, [FirstName] & " " & [LastName], ",")
REPLACE REPLACE(<old_text>, <start_num>, <num_chars>, <new_text>)
VALUE VALUE(<text>)
FIND FIND(<find_text>, <within_text>[, [<start_num]])
V. FORMULAS IN DAX

TIME INTELLIGENT FUNCTIONS

Format Syntax Define


PREVIOUSDAY PREVIOUSDAY(<dates>) Trả về giá trị ngày hôm qua
PREVIOUSMONTH PREVIOUSMONTH(<Dates>) Trả về giá trị tháng trước
PREVIOUSQUARTER PREVIOUSQUARTER(<dates>) Trả về giá trị quý trước
PREVIOUSYEAR PREVIOUSYEAR(<dates>[,<year_end_date>]) Trả về giá trị năm trước
Trả về giá trị cùng kỳ năm trước ( dùng cho tháng, quý)
Nó tương đương với giá trị được trả về của DATEADD
SAMEPERIODLASTYEAR SAMEPERIODLASTYEAR(<dates>) (ngày, -1, năm)
TOTALMTD
https://inda.vn/powerbi/cach-dung-mtd-qtd- MTD: Month to Date
ytd-trong-power-bi/ TOTALMTD(<expression>,<dates>[,<filter>]) Tính lũy kế trong tháng
TOTALQTD TOTALQTD(<expression>,<dates>[,<filter>]) Tính lũy kế trong quý

TOTALYTD TOTALYTD(<expression>,<dates>[,<filter>][,<year_end_date>]) Tính lũy kế trong năm


V. FORMULAS IN DAX

TIME INTELLIGENT FUNCTIONS

Format Syntax Define


Trả về kết quả là 1 bảng được lọc bởi 1 khoảng ngày
DATESBETWEEN DATESBETWEEN(<Dates>, <StartDate>, <EndDate>) StartDate, Enddate có thể là 1 Expression
Hàm EOMONTH giúp trả về giá trị ngày cuối tháng (gồm
cả ngày, tháng, năm) cách thời điểm mốc thời gian được
chọn theo khoảng thời gian tương ứng với số tháng quy
EOMONTH EOMONTH(<start_date>, <months>) định.
Giá trị trả về là cột chứa giá trị ngày nhỏ nhất trong số
FIRSTDATE FIRSTDATE(<dates>) những ngày được xét trong <Cột chứa giá trị thời gian>
LASTDATE LASTDATE(<dates>) Giá trị trả về là cột chứa giá trị ngày nhỏ nhất trong số
những ngày được xét trong <Cột chứa giá trị thời gian>.
V. FORMULAS IN DAX

TIME INTELLIGENT FUNCTIONS

Format Syntax Define


Là cột chứa giá trị ngày nhỏ nhất trong cùng tháng trong
STARTOFMONTH(<dates>) số những ngày được xét trong <Cột chứa giá trị thời
STARTOFMONTH gian>.
STARTOFQUARTER(<dates>) Là cột chứa giá trị ngày nhỏ nhất trong cùng quý trong số
STARTOFQUARTER những ngày được xét trong <Cột chứa giá trị thời gian>.
STARTOFYEAR(<dates>) Là cột chứa giá trị ngày nhỏ nhất trong cùng năm trong số
STARTOFYEAR những ngày được xét trong <Cột chứa giá trị thời gian>.
ENDOFMONTH ENDOFMONTH(<dates>) Hàm ENDOFMONTH giúp trả về giá trị ngày lớn nhất
trong cùng tháng với ngày được xét (End Of Month).
ENDOFQUARTER(<dates>) Là cột chứa các giá trị ngày lớn nhất trong số những ngày
ENDOFQUARTER có cùng 1 quý.
ENDOFQUARTER ENDOFYEAR(<dates>) Là cột chứa các giá trị ngày lớn nhất trong số những ngày
có cùng 1 năm
V. FORMULAS IN DAX

OTHER FUNCTIONS

Format Syntax Define


BLANK BLANK() Returns a blank.
Returns the value in the column prior to the specified number of
table scans (default is 1).
EARLIER EARLIER(<ColumnName> [,<Number>]) Earlier = current row
Returns the value in the column for the very first point at which
EARLIEST EARLIEST(<column>) there was a row context.

ERROR IFERROR(value, value_if_error) Nếu giá trị N/A lỗi thì trả về giá trị gì
VAR VAR <name> = <expression>
[VAR <name2> = <expression2> [...]]
RETURN <result_expression>
Sử dụng tham số cho các cú pháp measure
SUMMARIZECOLUMNS
SUMMARIZECOLUMNS( <groupBy_columnName> [, < groupBy_columnName
>]…, [<filterTable>]…[, <name>, <expression>]…) Trả về một bảng bao gồm các kết hợp giá trị từ các cột được
cung cấp dựa trên cách nhóm được chỉ định. Chỉ các hàng có
ít nhất một trong các biểu thức được cung cấp trả về giá trị
không trống mới được đưa vào bảng được trả về. Nếu tất cả
các biểu thức đánh giá thành BLANK / NULL cho một hàng, thì
hàng đó không được bao gồm trong bảng được trả về.
ADDCOLUMNS(<table>, <name>, <expression>[, <name>, <expression>]…)
VD:
dimDate=ADDCOLUMNS(CALENDAR("2022-01-01","2022-03- Trả về một bảng có tất cả các cột ban đầu và những cột được
ADDCOLUMNS 31"),"year",year([Date])) thêm vào.
VI. CREATE A DASHBOARD
VI. CREATE A DASHBOARD
VI. CREATE A DASHBOARD

Add more visuals

Bước 3: Click biểu


tượng giỏ hàng của
biểu đồ cần add

Bước 1
Bước 2

Bước 4: Click “Add” để add thêm biểu đồ


VI. CREATE A DASHBOARD

Publish Dashboard lên Power BI Service


Mục đích: Xem trên web, app
Click Publish->Save->My workspace-> Select -> Open ‘Your dashboard’ in Power BI
Để xem báo cáo trên Power BI service -> Đăng nhập account
VI. CREATE A DASHBOARD

Publish web:
Mục đích: Xem bằng đường dẫn (không cần đăng nhập hoặc có tài khoản)
Trên màn hình web: Chọn File -> Publish web -> Copy đường link

Bước 1

Bước 2
THANK YOU FOR LISTENING

You might also like