[Study notes] PowerBI data analysis and visualization - B station data white

References

Bilibili Video-Power BI Data Analysis and Visualization

foreword

Possible errata in the original video are edited in the notes. Ctrl+F search for "errata" can quickly locate the errata.
Possible discrepancies from the original video are mentioned in the notes. Ctrl+F searches for the word "difference" to quickly locate the errata.

2. Modeling and DAX functions

2.01 Establish a relational model

insert image description here
Tables can be divided into dimension tables and fact tables. The
fact table is used for calculation and the dimension table is used for screening
. You can quickly delete the relationship and other operations. The arrow of the relationship in the model table indicates the direction of filtering




2.01.1 Common problems when establishing relationships

  • Star structure (depth is 1)
    recommended
  • The snowflake structure (depth greater than 1)
    insert image description here
    is not recommended, and the product category table can be flattened into the product category. By combining queries, two tables can be turned into one table.
  • Model 1 to be optimized
    insert image description here
    can internalize the "discount amount" in "order discount" into the "order information" table
  • Model 2 to be optimized will have problems in this way. There will be ambiguity when passing the geographic information table to the order table . The geographic information table may be internalized into the customer table and the store information table
    insert image description here
    through the store information table or the customer table.

2.02 Understanding Power BI Core - Metrics

You can create a new metric value
[metric value] and you can directly reference the ready-made metric value

  • Counting function
    count: count ignoring text
    counta: count not ignoring text
    distinctcount: distinct count

  • The measurement value can be placed in the measurement value table:
    click the input data on the home page tab, the name is "1 measurement value table", and click load.
    Then click on the measurement value, and in the measurement tool, change the main table to "1 measurement value table" (this name is chosen to make this table rank at the top, and the table is sorted by characters)

Which table the measure is in does not affect the calculation

2.03 The most powerful function CALCULATE

In Visualization-Matrix, rows are filters and values ​​are calculations. Filtering and calculation are separate.
The CALCULATE function can both filter and calculate.
The syntax is

度量值 = CALCULATE(表达式, [筛选器1], ....)
如北区销售额=CALCULATE(SUM('订单信息'[金额]), '客户信息'[区域]=“北区”)

If there are filters in both matrix and measure formulas, and the two filters conflict, the formula will prevail. Superimpose if not conflicting.

2.04 Time intelligence series - DATEADD, TOTALYTD functions

This section calculates YoY, MoM, Cumulative, Yearly Cumulative YoY.

  • Year-on-year
    (sales of the current month - sales of the current month of last year) / sales of the current month of last year
# 先计算度量值:去年同期
# 专门做日期推移的函数:DATEADD(Dates, NumberOfIntervals, Interval)
去年同期 = CALCULATE([销售额], DATEADD('日历'[日期], -1, year))
# 再计算同比
# 用/来做除法,如果分母为0,结果会为无穷大。
# 用divide来做除法, 如果分母为0,结果会显示为空。
同比 = divide([销售额]-[去年同期], [去年同期])
  • Month-on-month
    (sales of the current month - sales of the previous month) / sales of the previous month
环比 = DIVIDE([销售额]-CALCULATE([销售额], DATEADD('日历'[日期], -1,MONTH)), CALCULATE([销售额], DATEADD('日历'[日期], -1,MONTH)))
  • Cumulative annual sales
    The sum of sales from the first day of the year to this day
# TOTALYTD是按年计算累计,每一年是独立的,即月的累计只会考虑当年的月
# TOTALQTD是按季计算累计
# TOTALMTD是按月计算累计
# TOTALYTD(表达式,Dates, [筛选器], [YearEndDate]:在应用指定的筛选器后,针对从该年度的第一天开始到指定日期中的最后日期结束的间隔,计算指定的表达式的值)
年累计 = TOTALYTD([销售额],'日历'[日期])
  • Year-on-year cumulative year-on-
    year (accumulated in the current month-accumulated in the current month of last year)/accumulated in the current month of last year
去年同期年累计 = CALCULATE([年累计], DATEADD('日历'[日期], -1,year))
年累计同比 = DIVIDE([年累计]-[去年同期年累计],[去年同期年累计])

2.05 Calculate moving average - DATEINPERIOD function

This section calculates the "Prior 3 Months Sales" and "3 Months Moving Average".
Looking at sales purely on a monthly basis, the fluctuations are relatively large, and it is not easy to see the trend. Moving averages are less volatile and easier to see trends.

  • 3-month moving average
    The sum of the sales of 3 months forward / the number of months (if it is insufficient, it will be counted according to the actual number of months)
# 先计算度量值:前3个月销售额
# 专门求日期区间的函数:DATEINPERIOD(Dates, StartDate, NumberOfIntervals, Interval)
前3个月销售额 = CALCULATE([销售额],DATESINPERIOD('日历'[日期],  MAX('日历'[日期]), -3, MONTH))
# 计算3个月移动平均
3个月移动平均 = DIVIDE([前3个月销售额], CALCULATE(DISTINCTCOUNT('日历'[年月]), DATESINPERIOD('日历'[日期], MAX('日历'[日期]), -3, MONTH)))

Formulas can be formatted and aligned to help understand

  • Convert to a line chart
    Convert directly to a line chart, the format is wrong. Select "Visual" in "Format View Object" under Visualization and change the x-axis to Category instead of Continuous.
    The default is to sort in descending order, click "More Options" in the upper right corner of the chart, and select the sorting axis as year and month. and select Sort Ascending.

2.06 A function that can clear the filter - ALL() function

This section calculates "Total Sales", "Total Proportion" and "Date Intuitive Proportion".

  • Total Proportion
    Total Proportion = Sales of a certain product category in a certain region / total sales
# 先计算度量值:总销售额
# 用于清除筛选条件的函数:ALL([TableNameOrColumnName], [ColumnName1], ...)
# 可以清除引用表的所有筛选,或者引用列的所有筛选
总销售额 = CALCULATE([销售额],ALL('订单信息'))
# 计算总占比
总占比 = DIVIDE([销售额],[总销售额])
  • Intuitive proportion of date
    On the basis of the total proportion, we hope to add a date slicer (to filter the date). However, the above filter for the total sales will also clear the date of the filter. Therefore, we need a more fine-grained clearing filter (only the region column in the customer information table and the product category column in the product information table are cleared). The intuitive proportion of date = sales of a certain product
    category in a certain area / total sales (date Modifying the date range in the slicer will filter the date)
# 先计算度量值:所有区域和类别
所有区域和类别 = CALCULATE([销售额], ALL('客户信息'[区域]), ALL('产品信息'[产品类别]))
# 再计算日期直观占比
日期直观占比 = DIVIDE([销售额],[所有区域和类别])

If the cleared filter is listed in the same table, it can be written in one ALL function;
otherwise, multiple ALL functions should be written.
The following is an error demonstration

insert image description here

2.07 Intuitive proportion analysis - ALLSELECTED function

If you go ahead and add "Slicer on Region" and "Slicer on Product Category". And we hope that the filter of the slicer is still valid, and the filter of the matrix is ​​invalid. It is impossible to use the above formula. because

所有区域和类别 = CALCULATE([销售额], ALL('客户信息'[区域]), ALL('产品信息'[产品类别]))

Not only will the filter of the matrix be removed, but also the filter of the slicer will be removed.
To achieve our needs, we need to use the ALLSELECTED function

# 先计算度量值:清除行列筛选
# 用于仅清除视觉对象-矩阵中的筛选,而不清除外部筛选器的函数:ALLSELECTED([TableNameOrColumnName], [Column])
清除行列筛选 = CALCULATE([销售额], ALLSELECTED('客户信息'[区域]), ALLSELECTED('产品信息'[产品类别]))
# 再计算直观占比
直观占比 = DIVIDE([销售额],[清除行列筛选])

2.08 Classification Proportion Analysis - ISFILTERED Function

In the visual-matrix, add a first-level class: Product Category, and a second-level class: Product.
It 分类占比means:
the proportion of the product = the sales of the product / the sales of the product category of the product
The proportion of the product category = the sales of the product category / the total sales

# 用于判断筛选级别的函数:ISFILTERED(TableNameOrColumnName)
分类占比 = DIVIDE([销售额],IF(ISFILTERED('产品信息'[产品]), CALCULATE([销售额],ALL('产品信息'[产品])), CALCULATE([销售额],ALL('产品信息'[产品类别]))))
# 为了使外部切片器的筛选保留,需要将两个ALL函数改为ALLSELECTED函数
分类占比 = DIVIDE([销售额],IF(ISFILTERED('产品信息'[产品]), CALCULATE([销售额],ALLSELECTED('产品信息'[产品])), CALCULATE([销售额],ALLSELECTED('产品信息'[产品类别]))))

2.09 Powerful filter function - FILTER function

The screening in the calculate function mentioned above is relatively simple, and can only be screened based on a certain field.
The FILTER function is a special function for filtering.

  • Use the FILTER function to realize the previous measurement value "Sales in North District"
# 专用于筛选的函数:FILTER(表, FilterExpression)
# 将之前写的北区销售额公式也放过来做比较
北区销售额=CALCULATE([销售额], '客户信息'[区域]=“北区”)
北区销售额2 = CALCULATE([销售额],FILTER('客户信息', '客户信息'[区域]="北区"))

The returned result
insert image description here
is analyzed based on the calculation process of the value of the "North District Sales 2" column in the "East District" row:
1. After the rows are filtered, only the customers in the East District are left.
2.FILTER('Customer Information', 'Customer Information'[Area] = "North District") indicates that in the already filtered "Customer Information" table, continue to filter "North District" customers, because there is no intersection, so it is an empty table .

In PowerBI, if a metric value is empty, its corresponding dimension will not be displayed by default.

insert image description here
If you want "North District Sales 2" to achieve the same effect as "North District Sales", modify the table parameters of FILTER and use the ALL function to clear the filter on the customer information table

北区销售额2 = CALCULATE([销售额],FILTER(ALL('客户信息'), '客户信息'[区域]="北区"))
  • Number of customers with sales greater than 50 million
销售额大于5千万的客户数 = CALCULATE([客户数], FILTER('客户信息', [销售额]>50000000))

FILTER is an iterative function that will be judged line by line

  • Months with sales greater than 20 million
# FILTER的第一个参数必须是一个表,这里要求销售额大于2千万的月份,必须是包含不重复年月信息的表,但我们没有现成的表
# 用于”对某个表的某一个列去重,生成一个新的表“的函数:VALUES(TableNameOrColumnName)
销售额大于2千万的月数 = CALCULATE(DISTINCTCOUNT('日历'[年月]), FILTER(VALUES('日历'[年月]), [销售额]>20000000))

The filter table filters the table in parameter 1 row by row, so the filtered fields must come from the table in parameter 1.

2.10 SUMX class functions

2.10.1 Optimize the "monthly sales with sales greater than 20 million" in the previous section, the total becomes an intuitive total

# 略微修改上一节的函数可以得到
销售额大于2千万的月数销售额 = CALCULATE([销售额], FILTER(VALUES('日历'[年月]), [销售额]>20000000))

But there will be a problem in this way, the total display of the summary will be abnormal (not the intuitive summary of the measurement value): the
insert image description here
reason for this is that the "total" line does not filter the "area", so the meaning of the expression is "considering all areas" The sum of monthly sales, considering the number of months with sales greater than 20 million and the number of months with sales greater than 20 million in sales".

But we want the grand total to be a visual summary of the measures in this column. There are three ways to handle totals at this point:

  • Method 1: Mask Totals
# 利用总计没有经过区域的筛选来屏蔽总计
# 使用IF+ISFILTERED+BLANK函数
销售额大于2千万的月数销售额2 = if(ISFILTERED('客户信息'[区域]), CALCULATE([销售额], FILTER(VALUES('日历'[年月]), [销售额]>20000000)), BLANK())
# IF的第三个参数默认为空,BLANK()也表示空。所以这里的BLANK()可填可不填

But there is a problem with this method. When using the "slicer for selecting an area to filter", powerbi thinks that the total has been filtered by the area, so the total will still be displayed

# 利用总计没有经过在区域列内来屏蔽总计
# 使用IF+ISINSCOPE+BLANK函数
销售额大于2千万的月数销售额2 = IF(ISINSCOPE('客户信息'[区域]), CALCULATE([销售额], FILTER(VALUES('日历'[年月]), [销售额]>20000000)), BLANK())
  • Method 2: Set not to display the total
    Select the matrix, in the "Format Visual Object", find "Row Subtotal", and remove the check on the right
  • Method 3: Totals display visual summaries - use the SUMX function
# SUMX(表, 表达式)
销售额大于2千万的月数销售额3 = SUMX(VALUES('客户信息'[区域]), [销售额大于2千万的月数销售额])
# 先逐行迭代第一个表参数的行,并计算相应的度量值[销售额大于2千万的月数销售额]
# 然后再进行求和
销售额大于2千万的月数销售额3 = SUMX(VALUES('客户信息'[区域]), [销售额大于2千万的月数销售额])

Process Analysis

  1. Row filtering: perform row filtering first, such as "Eastern District"
  2. Table: Then, on the basis of 1, a new table is obtained according to the VALUES function, which is a table with only one row "Eastern District"
  3. Add a column to the table: iterate the table in 2 row by row, and calculate the corresponding "[sales in months with sales greater than 20 million]"
  4. Sum the newly added columns: sum the results obtained in 3

The process is the same for totals.

"Row total" is essentially equivalent to clearing all rows and then calculating the measurement value.
SUMX is also an iterative function.
Similar to SUMX, there are iterative functions such as AVERAGEX and MAXX. Their difference is mainly in the fourth step of the above process analysis.

2.10.2 Optimize the "number of customers with sales greater than 50 million" in the previous section, and change the total to the average

# 应用AVERAGEX函数
销售额大于5千万的客户数2 = AVERAGEX(values('客户信息'[区域]), [销售额大于5千万的客户数])

2.11 Ranking analysis - rankx and topn functions

  • Product sales ranking
# 用于计算排名的迭代函数:RANKX(表, 表达式, [值], [Order], [Ties])
排名 = RANKX(all('产品信息'), [销售额], [销售额], DESC, Dense)
# 去掉总计版本
排名 = IF(ISINSCOPE('产品信息'[产品]), RANKX(all('产品信息'), [销售额], [销售额], DESC, Dense))

Process analysis:

  1. Row filtering: First perform row filtering, such as the product "Computer-Y2"
  2. Table: After ALL("product information"), the row filter will be cleared and the table will be obtained
  3. Add a column to the table: iterate the table in 2 line by line, calculate the corresponding "[Sales]", and get a reference table
  4. The value used for comparison: if not specified, the default is the second parameter. Here it is [Sales], with an external context. In other words, what is shown here is the sales of "Computer-Y2".
  5. Order-ranking method: in ascending or descending order, the default is in descending order
  6. Ties-ranking method: whether it is compact (Dense) or skipping (Skip), the default is skipping
  7. Returns the rank of the value used for comparison in the reference table

Recommended reading: Detailed explanation of RANKX function - Zhihu - BI Luo
Errata: The teacher made a slip of the tongue at 3 minutes and 47 seconds of the video. Below Ties
is a graph testing the default parameters of Ties.
insert image description here

  • The sales ranking of the product in the product category-the ranking within the group
    Add row indexes to the matrix: "product category", "product", and a matrix with multi-layer indexes can be obtained.
    The default is 压缩式the layout (products and product categories are displayed in one column), as shown below.
    insert image description here
    In the "Options" of the "Row Header" in the "Format Visual Object", uncheck the right side of the "Gradient Layout" to get the perfect layout 表格式.
    insert image description here
排名(组内) = RANKX(all('产品信息'[产品]), [销售额], [销售额], DESC, Dense)

Process analysis:

  1. Row screening: first perform row screening, such as product type "mobile phone", product "mobile phone-X3"
  2. Table: After all('product information'[product]), the screening of the product "Mobile Phone-X3" will be cleared, leaving only the screening of the product type "Mobile Phone", and Table 2 is obtained
  3. Add a column to the table: iterate table 2 row by row, calculate the corresponding "[Sales]", and get a reference table
  4. The value used for comparison: the value with the external context, that is, the product type is "mobile phone" and the product is the sales of "mobile phone-X3".
  5. Returns the rank of the value used for comparison in the reference table
  • The sales of the top few customers every month
    can also be calculated by using the previous calculate+filter function (filter ranking less than or equal to 5), but it is more troublesome.
    The TOPN function is introduced below.
# 专门用于筛选前几名的函数:TOPN(N_Value, 表, [OrderBy_Expression1], [Order1], ...)
前5名客户销售额 = CALCULATE([销售额], TOPN(5, '客户信息', [销售额]))
前5名客户销售额占比 = DIVIDE([前5名客户销售额], [销售额])
  • Change "sales" and "top 5 customer sales proportion" into "line and clustered column chart"
    insert image description here

2.12 Using Power BI functions in Excel

  • The Data Query Editor
    is in the "Get Data" section of the "Data Tab".

  • Modeling analysis capabilities - Power Pivot
    for building relationships and writing measures

    • How to add the Power Pivot tab
      Right-click the Start tab, click "Customize the Ribbon", click "Add-ins", click "COM Add-ins", then click "Go", and then check "Microsoft Power Pivot for Excel" , click OK.
      insert image description here
  • Get Data
    In "Get Data" of "Data Tab", select "Get Data", "From File", "From Excel Workbook".
    After selecting "Convert Data", enter the Power Query editor, after modifying the data type, click "Close and upload" or "Close and upload to"

    • "Close and upload" will upload the data to the worksheet
    • "Close and upload to" can upload data to "Create link only", and check "Add this data to the data model" (generally use this for analysis)
      insert image description here
  • Click the "Management" option of the "Power Pivot" tab.
    Writing the measurement value is slightly different. You need to add an English colon before the equal sign, such as

销售额:=sum(订单信息'[金额])

2.13 Powerful cube function in Excel - CUBEVALUE function

The data in the model can be used in Excel, which is very flexible. But the appearance will be limited by the pivot table.
In order to make the appearance more flexible, you can select "Pivot Table", then click the "Pivot Table Analysis" tab, then click "OLAP Tools", and then click "Convert to Formula". At this time, the values ​​​​of the pivot table become the values ​​​​obtained by the CUBEVALUE calculation formula.

# 专用于多维数据集的函数:CUBEVALUE(connection, [member_expression1], [member_expression2], ...)
# 它可以引用模型里的数据和度量值,也可以使用切片器
CUBEVALUE(”模型名称“, "[客户信息].[区域].[All].[北区]", "[产品信息].[产品类别].[All].[电脑]", "[Measures].[销售额]", "切片器_年", "切片器_月")
# 注意必须用双引号
# Measures引用的是度量值
# 最后可以加上使用的切片器,切片器的名字可以通过右键切片器,点击”切片器设置“查看。

3. Visualization

3.01 Comparative Analysis Scenario Chart Making and Drilling Interaction

Comparative analysis scenarios: Which product categories are selling well and which product categories are not selling well.
Answer: You can use a bar chart (the third visual object) or a column chart (the fourth visual object) to express. Here is an example of a histogram.

3.01.1 Chart making

  1. Click on the column chart, drag the X-axis into the product category, and drag the Y-axis into the sales volume
  2. Make additions, deletions, and modifications. Add: Add missing key information: such as data labels; Delete: Delete redundant operations: such as Y-axis title, Y-axis label; Change: Adjust information: For example, the title name can be modified to a conclusion that the data can support
  • Color adjustment
    The screenshot software can also obtain the RGB value of the color.
    You can set the default color to a light color (or gray) of the same color system, and set the color of the field to be highlighted to a dark color to highlight the
    color mode. In addition to RGB, there is also HSL Mode: Hue (U), Saturation (S), Brightness (L)
    You can adjust the brightness to obtain light or dark colors of the same color system.
    You can directly search for "color" in "Set visual object format" to quickly View the color format to be set

  • Add constant line, average line, etc.
    Click the third in the "Visualization Module": "Add further analysis to visual objects", you can add constant line (standard line) or average line (more used), etc.
    insert image description here

3.01.2 Drill Interaction

Click on the first one in the "Visualization Module": "Add Data to Visuals" and drag the low-level "Product" field to the X-axis below "Product Category". A drill down button will appear in the upper right corner of the column chart. Click the drill down button in the upper right corner of the column chart.
insert image description here
Then click on a column to drill down.

3.02 Trend Analysis Scenario Chart Making

Scenario: I want to see the trend of monthly sales.
Answer: It can be realized through a line chart (the first in the second row of the visual object) or a zone chart (the second in the second row of the visual object). Here is a line chart as an example.

3.02.1 Chart making

Click on the line chart, drag the X-axis to [calendar] month, and drag the Y-axis to sales (modify sorting)

By default, they are sorted in alphabetical order, so maybe October, November, and December will be before January. At this time, the data view finds the calendar table, selects the column tool to sort by column, and sorts by month number.
Putting the year in the legend can divide the two-year data into two line charts for comparison. You
can also put the year on top of the month on the X-axis, and then drill or expand the
expanded X-axis labels. The order may not be correct, you can First change to descending order, and then change back to ascending order to make the order expand normally.
After the axis label of the X axis will bring the label of the previous level, such as "January 2019", you can disable it by unchecking the "Connection label" of the visual object. Labels of the previous level

3.02.2 Combination diagram

A combined chart is when the same chart has two different indicators. Generally, "line and clustered column chart" (the fifth in the second row of the visual object) are used to represent.
Click "Polyline and Clustered Column Chart", drag the year and month on the X axis, drag the sales on the column Y axis, drag the gross profit rate on the row Y axis, and then click to expand

For readability, it is best to match the color of the axis labels to the color of the graph.

insert image description here

3.03 Proportion Analysis Scene Graph Production

Scenario: I want to see which area is more important.
Answer: It can be achieved through a pie chart (the 4th in the third row of the visual object) or a donut chart (the 5th in the 3rd row of the visual object). The ring chart is more recommended, which looks better. Here we take the ring chart as an example.

3.03.1 Ring chart

Click on the ring chart, drag the area in the legend, and drag the sales in the value

The disadvantage of using a legend is that it cannot be seen clearly when there are many categories. So in general, uncheck the legend in the visual object format, and then in the details tab, change the label content to "category, total percentage"

insert image description here

3.03.2 Dendrogram

If there are more than 6 categories, it is not suitable to be displayed in a pie chart or ring chart. At this time, a dendrogram is suitable.
You can use Format-Color-Advanced Controls to make the color of the dendrogram achieve a gradient effect.
insert image description here
By putting regions into categories, provinces into details, and sales into values, a dendrogram with hierarchical division can be obtained.
insert image description here

3.03.3 Stacked charts (stacked bar charts, stacked column charts, stacked area charts, and percentage stacked columns)

  • stacked column chart
X轴:年、季度
Y轴:销售额
图例:区域

insert image description here

  • Percentage stacked column chart (most used)
    insert image description here

3.03.4 Waterfall Chart

Want to know what the total sales are made up of. You can use a waterfall chart (the first in the third row)

类别:产品类别
Y轴:销售额

insert image description here
Waterfall charts can also be used to explain growth or decline

类别:年
细目:区域
Y轴:销售额

insert image description here

3.03.5 Decomposition tree

The decomposition tree (row 6, 1st) can also explain the composition, which is very useful when doing presentations.

分析:销售额
解释依据:区域、年、产品类别

insert image description here

3.04 Create a Scene Graph for Correlation Analysis

Scenario: I want to see which products are easy to sell and more profitable. These products can be placed in places with relatively large traffic.
Answer: This requires the use of two indicators to correlate, and the graph used is a scatter plot (the third in the third row).

3.04.1 Scatter plot

值:产品类别
X轴:销量
Y轴:毛利率
勾选类别标签
添加2条平均值线(一条的数据系列是“销量”,一条的数据系列是“毛利率”)
大小:销售额   # 这样散点的大小就会根据销售额大小变化

If you drag "Product Category" from "Value" to "Legend", you can use color to distinguish different categories.
In addition to adding year and month slices with the slicer, you can also drag "calendar [year and month]" to the playback axis.
When playing, click on the scatter, and you can see the trajectory of the scatter. Press Ctrl to select multiple at the same time.

insert image description here

3.05 Make distribution analysis scene graph

Scenario: I want to see the sales situation of each province
Answer: Use the earth map (the first item in the 4th line)

3.05.1 Earth Map

位置:省份
图例:区域
气泡大小:销售额
勾选类别标签

Three reasons may cause the earth map to fail to display: 1. No internet connection 2. Powerbi is in English, but the data is in Chinese provinces 3. Security (can be set in the file options)

insert image description here

  • Heatmap
    converts the normal earth map above into a heatmap.

Because the legend of the earth map and the heat map are distinguished by color, the legend of the earth map must be deleted before conversion can be performed.
Heat maps are suitable for scenes with a lot of locations.

insert image description here

3.05.2 Coloring the map

Colored maps (2nd in row 4) use color blocks to identify areas.

位置:省份
格式中的填充颜色,选择条件格式,选择基于“销售额”的“渐变”的填充颜色。

3.05.3 Charting of Hierarchical Distributions

For the distribution of age levels and the distribution of purchase quantities, you can first create a new group and divide the levels according to the rules. Then draw the graph again.
step:

  1. In the data view, find the order quantity column of the order information table, right-click "Add Group", and then select "Packing Size" as 20. This will result in a new grouping "Order Quantity (Box)" with a box size interval of 20
    insert image description here
  2. Add a clustered column chart, drag the X-axis into "Order Quantity (Box)", and drag the Y-axis into "Times".

In order to count the quantity of an order - the quantity corresponding to the box (number of lines), introduce the measurement value "times=Countrows('order information')"

  1. You can find the order quantity (box) in the data view, and then modify the format to ">0", as in excel, 0 represents a placeholder.

It is also possible to convert a column chart to an area chart.

3.06 Slicer scene application

3.06.1 Three slicers

  • text slicer

You can modify the style in the slicer settings: vertical list, tile, drop-down

insert image description here

  • Numeric Slicer
  • date slicer

You can click Filters to add data fields to filter on in the visual or on this page or on all pages.

3.06.2 Slicer controls other pages

Select the slicers you want to sync, then click View, then click Sync Slicers. You can check the pages to be synchronized.
insert image description here

On the left is the synchronization column and on the right is the display column.
In this way, all slicers can be placed on the first page and not displayed on other pages.

3.07 Guiding Business Decisions: What-If Analysis

3.07.1 Card Map

Displays a single metric value (key indicator) commonly used card map (the 4th in the 4th row).
insert image description here

3.07.2 Create a new value table

To create a new value table, you can import it by creating a table.
You can also click "New Parameter" in the "Modeling" tab, drop down "Value Range", fill in the parameters, and then click OK. will generate a table, a slicer and a 一个受切片器筛选的度量值.

3.07.3 Optimize the "Top 5 Customer Sales Proportion" designed in 2.11

Use 一个受切片器筛选的度量值the graph that can dynamically obtain the sales ratio of the top N customers.
Replace the position of the original fixed value with 一个受切片器筛选的度量值.

3.07.4 Dynamically control titles with metrics.

  1. First construct a metric that returns a text type, such as:动态标题=”前“&[选择数字 值]&"名客户销售额占比"
  2. Then in the title of the chart's formatting general, click "fx" in the text. Apply the "Dynamic Title" field value.
    insert image description here

3.08 Dynamic coordinates and dynamic indicators

By going to the Modeling tab, click New Parameter, drop down Fields, and move the required fields to the left. will generate a table, a slicer and a 一个受切片器筛选的度量值.
This metric can be placed on the x-axis of the visual.
In this way, the axis field can be dynamically selected through the slicer.

Indicators can also be selected similarly dynamically.
It is recommended that the slicer be set to single selection. Of course, in the case of multiple selections, data drilling can be performed.

insert image description here

3.09 Editing interactive effects

3.09.1 ​​Convenient typesetting by setting the background color

Click the blank space of the background, select "Format Report Page" in "Visualization", and modify the background of the canvas to "light color" and "0" transparency. Then you can adjust the layout according to the red line.

3.09.2 Filter to filter

Place the cursor over the filter funnel of the graph, and it will prompt which filters are applied.
insert image description here

3.09.3 Editing Interaction - Using a Chart to Filter Other Charts

Click on a chart, then click on the "Format" tab, and then click on "Edit Interaction", at this time 3 icons will appear for other charts.
insert image description here
From left to right: filter (most commonly used), highlight (default), none (no filtering)

After setting the editing interaction, click "Edit Interaction" again to exit the editing state.

3.09.4 Locking objects

Click "Lock Object" under the "View" tab, so that the view object cannot be dragged. This avoids misuse of the view.

Lock objects work on the entire file.

3.10 Tooltips

There will be a hint when the cursor is placed on the icon, but it is too simple.
insert image description here

3.10.1 Simple Tooltip - Add Field

Select the view object, then click the "Add Data to Visual Object" tab, find the "Tool Tip" below, and the fields you want to be prompted can be added here.
insert image description here

3.10.2 Complex Tooltips - Tooltip Page

  1. Create a new tooltip page: Create a new page, then set the page format, and select the "tooltip" type in the canvas settings.
    insert image description here
  2. Set the tooltip page as a tooltip: select the view object to add a tooltip to, click the "Format Visual Object" tab, then select General-Tooltip, select the tooltip report page you just made, and move to the visual object , a tooltip for the report page type appears.
    insert image description here

3.11 Drilling across reports for reports

  1. New Drill Page: Create a new page, create a view object, and add a field (such as a region) under the drill in the page visual.
    insert image description here

  2. Drilling across reports: Right-click a field of the view object, drill, and select the drill page.
    insert image description here
    This will enter the drill page and pass the fields for filtering.

  3. Hold down Ctrl and click the left arrow. You can go back to the previous page.
    insert image description here

3.12 Natural Language Questions and Answers

3.12.1 Question and Answer-AI

Double-click an empty space on the page to enable this feature. Or click on the question and answer in the visual object (the second in the sixth row)
and enter "sales by customer" and it will be displayed. Note that there is a space in the middle.

It is also possible to directly write "dimension measurement", such as "customer sales",
you can add the English chart type to specify the type of chart drawn, such as pie, line
insert image description here

3.12.2 Add synonyms

You can modify the attributes of the fields in the model and assign synonyms to the fields. For example, the sales volume field can add the synonym "sales volume" (note that the commas are separated)
insert image description here
so that AI can also recognize the sales volume as sales volume.

3.13 Sharing with others: publication and updating of reports

  • Save the file and send it
    . The other party needs to have powerbi software to open it
  • Conference Room Presentation
    If you want to focus on a chart during presentation, you can select "Focus Mode".
    insert image description here
  • Publish to the online version
    Click "Publish" on the home page, you must register and log in before publishing.
    Enter the online version, and then share to the mailbox of a colleague (you will know whether you are a colleague of a company through the suffix of the mailbox).

The advanced Pro version can set access rights settings, and different people can see different content. And the Pro version can be refreshed regularly.
Email sending can only be sent to colleagues. Alternatively, select File - Embed Report - Publish to Web (Public), which will provide a URL. This report can be accessed through the URL.

  • Update
    Method 1: Refresh on the homepage, and then publish.
    Method 2: In the online version, click Data Center, find the data, and click Refresh Now

3.13 Dynamic presentation of Power BI report in PPT

method one:

  1. You must first register and log in, and publish the report, then select File - Embed Report - Publish to Web (Public), copy the embed code.
  2. Then in the PPT, select Insert, click Add-ins, get Add-ons, search in the app store: web viewer and add it.
    insert image description here
  3. Then paste the address in 1 and remove the repeated https prefix.

Method 2:
In the online version, directly share to PowerPoint, and the PPT will be automatically embedded.
insert image description here

4. Case

4.01 Fiscal Year Analysis

A fiscal year is defined as October 1st of a certain year to September 30th of the next year (errata). For example, the fiscal year of November 25, 2019 is 2020, and the fiscal month is February.

# 度量值设置
销售额 = SUM('订单信息'[金额])
去年同期(财年) = CALCULATE([销售额], '日历'[财年]= MAX('日历'[财年])-1)  # 差异
# up的写法:去年同期(财年) = CALCULATE([销售额], FILTER(ALL('日历'[财年]), '日历'[财年]=MAX('日历'[财年])-1))
同比%(财年) = DIVIDE([销售额] - [去年同期(财年)], [去年同期(财年)])
上月销售额(财年) = CALCULATE([销售额], FILTER(ALL('日历'), '日历'[财年财月编号] = MAX('日历'[财年财月编号]) -1 ))
环比%(财年) = DIVIDE([销售额]-[上月销售额(财年)], [上月销售额(财年)])
年累计(财年) = TOTALYTD([销售额], '日历'[日期], "9-30")
# 更通用的写法
年累计(财年) 2 = CALCULATE([销售额], FILTER(ALL('日历'), '日历'[财年]=MAX('日历'[财年])&&'日历'[财月编号]<=MAX('日历'[财月编号]))) 

Although the same period last year (fiscal year) = CALCULATE([sales], 'calendar'[fiscal year]= VALUES('calendar'[fiscal year])-1) can also achieve the effect. But if the row subtotal is turned on, if you use the values ​​function (the values ​​function returns a table at this time), the visual object will not be displayed.

4.02 Analysis of Sales Achievement

Scenario: There is a table with monthly sales targets for each region. It depends on the achievement rate.

4.02.1 Data processing

# 数据处理
转换-将第一行用作标题
对年字段-右键-向下填充
选中“年”和“区域”字段-右键-逆透视其他列
选中“年”和“月份”字段-右键-合并列-取名”日期“-将该列转换为“日期”格式
将“值”字段重命名为“目标”字段,数据类型改为整数,并添加后缀0000(点击转换-格式-添加后缀),再改为小数类型
修改表名为“目标表”
点击主页-关闭并应用
# 数据处理
# 由于客户信息表和目标表的区域关系是多对多的。所以考虑在目标表增加一列能代表区域的“客户代码”,用于与客户信息表建立关系
在excel中将客户代码和区域列复制,然后对区域列去重

insert image description here

Although columns can also be added in the model, it is more standard to add them in the data collation step. Go to Home Page - Convert Data

点击目标表,添加列,条件列,写条件如下图,并将字段名改为“客户代码”,格式改为文本
关闭并应用
然后在模型视图将客户信息的客户代码与目标表的客户代码建立关系

insert image description here

4.02.2 Metrics

4.02.3 Change data source

4.03 Multidimensional Revenue Analysis

insert image description here

4.04 RFM Analysis

4.04.1 Introduction of RFM Model

insert image description here
insert image description here

4.04.2 Effects to be achieved

insert image description here

4.02.3 Metrics

insert image description here

Guess you like

Origin blog.csdn.net/zhangyifeng_1995/article/details/129692195