power bi条件格式

In this article, I’m going to explain what conditional formatting in Power BI is. Conditional formatting, as the name suggests, is a way of visualizing data that applies special format rules based on some pre-defined conditions on the values of a selected metric. It is mostly used when the data is presented in a tabular format; however, it can also be used in any charts such as bar charts, line charts, etc.

在本文中,我将解释Power BI中的条件格式是什么。 顾名思义,条件格式是一种可视化数据的方式,该数据基于对选定度量值的某些预定义条件应用特殊格式规则。 它主要用于以表格形式显示数据时使用。 但是,它也可以用于任何图表,例如条形图,折线图等。

Power BI中的条件格式是什么? (What is conditional formatting in Power BI?)

When there is a lot of data expressed in tabular format, it becomes difficult to understand which of the values are higher or lower at first glance. Often, you need to eyeball deeply into the cell values to understand or compare various metrics that are being displayed.

当以表格格式表示的数据很多时,乍一看就很难理解哪个值更高或更低。 通常,您需要深入了解单元格值以了解或比较所显示的各种指标。

For instance, if you consider the figure on the left below, there is just too much data and you need to compare each of the cell values individually in order to understand more about it. However, if you see figure on the right, you can understand just by looking at a single glance, what are the higher values, the middle values and which values are lower. This is known as conditional formatting in Power BI.

例如,如果您考虑下面的左图,那么数据太多了,您需要分别比较每个单元格值以了解更多信息。 但是,如果您看到右侧的图,则只需看一眼就可以了解,什么是较高的值,中间的值以及哪些值较低。 这在Power BI中称为条件格式。

设定资料 (Setting up data)

Let us first try to import some data into the Power BI data model. Once the data is imported, we will investigate how to implement conditional formatting. For the sake of this article, I’m going to import the data from the famous WideWorldImportersDW database that is provided by Microsoft. You can download and install this database on your local easily. Since I have already installed the database, I won’t be covering those steps here. In order to import the data into Power, you can walk along with me in the steps below:

让我们首先尝试将一些数据导入Power BI数据模型。 导入数据后,我们将研究如何实现条件格式。 为了本文的目的,我将从Microsoft提供的著名的WideWorldImportersDW数据库中导入数据。 您可以轻松地在本地下载并安装此数据库。 由于我已经安装了数据库,因此这里不再赘述。 为了将数据导入Power,您可以按照以下步骤与我同行:

  1. Get Data 获取数据”
  2. Select SQL Server from the dropdown that appears

    从出现的下拉菜单中选择“ SQL Server

    Figure 2 – Get Data in Power BI

    图2 –在Power BI中获取数据

  3. In the Connect Server dialog box that appears, provide the server name and the name of the database and click OK

    在出现的“连接服务器”对话框中,提供服务器名称数据库名称,然后单击“ 确定”。

    Figure 3 – Server Details

    图3 –服务器详细信息

  4. Connect using your credentials as required and click on Connect. In my case, I’m using Windows Authentication mode to connect to the database in SQL Server

    根据需要使用您的凭据进行连接 ,然后单击“ 连接” 。 就我而言,我正在使用Windows身份验证模式连接到SQL Server中的数据库

    Figure 4 – Authentication

    图4 –验证

  5. Once you click on Connect, you’ll see that all the tables from the database are listed in the dialog box. For this article, we will just select three of the tables – Dimensions.City, Dimensions.Date and Fact.Sale. Click Load once done:

    单击“连接”后,您将看到对话框中列出了数据库中的所有表。 对于本文,我们将仅选择三个表– Dimensions.CityDimensions.DateFact.Sale 。 单击完成后加载

    Figure 5 – Selecting Tables

    图5 –选择表

  6. All three tables will now be loaded into the Power BI data model and available on the data pane:

    现在,所有三个表都将被加载到Power BI数据模型中,并在数据窗格中可用:

    Figure 6 – Data Imported

    图6 –导入的数据

在Power BI中生成报告 (Building a report in Power BI)

Now, let us quickly build a Power BI report using the Matrix visualization. It will use the data from the tables that we just imported. Click on Matrix on the Visualizations pane and drag and drop the respective fields into the Rows, Columns and Values, as shown in the figures below:

现在,让我们使用Matrix可视化工具快速构建Power BI报告。 它将使用我们刚刚导入的表中的数据。 单击“ 可视化”窗格上的“ 矩阵 ”,然后将相应的字段拖放到“ 行” ,“ 列”和“ 值”中,如下图所示:

Once the fields are in place, you’ll see a similar kind of matrix being created in the Power BI report. This is a simple matrix that displays the sum of Total Including Tax for each of the Sales Territory and by Year. As you can see, it’s not easy to understand the highest and lowest values in the matrix; we need to dive deep into the visual and understand those values.

字段到位后,您将在Power BI报表中看到正在创建的类似矩阵。 这是一个简单的矩阵,显示每个销售地区和按年份总含税总额 。 如您所见,要了解矩阵中的最大值和最小值并不容易。 我们需要深入了解视觉并理解这些价值。

在Power BI中实施条件格式 (Implementing conditional formatting in Power BI)

In order to implement conditional formatting in Power BI, let us go ahead and define the rules for which we would like to visualize. Let us consider that we will change the background color of the cells based on the values each cell holds. For instance, the cell with the lowest value will have a background color of red while the highest will be highlighted in blue. You can follow the steps below to implement the same.

为了在Power BI中实现条件格式设置,让我们继续并定义要可视化的规则。 让我们考虑我们将基于每个单元格所保存的值来更改单元格的背景色。 例如,具有最低值的单元格将具有红色的背景色,而具有最高值的单元格将以蓝色突出显示。 您可以按照以下步骤实施。

  1. Right-click on the “Total Including Tax” field in the Values section
  2. 右键单击“ 值”部分中的“ 含税总额 ”字段
  3. Select Conditional Formatting and then click on the Background color

    选择条件格式 ,然后单击背景色

    Figure 10 – Conditional Formatting

    图10 –条件格式

  4. Alternatively, you can also click on the Format button and turn on the Background Color under Conditional Formatting

    或者,您也可以单击“ 格式”按钮,然后在“ 条件格式”下打开“ 背景色

    Figure 11 – Conditional Formatting

    图11 –条件格式

  5. The Background Color – Formatting dialog box opens

    “背景色-格式设置”对话框打开

    Figure 12 – Background Color

    图12 –背景颜色

  6. Let us now select Color Scale as the Format By option and select the colors as discussed earlier. For the Lowest value, we will assign red while the color for the Highest value will be blue. Click OK once done

    现在让我们选择“ 色阶”作为“ 格式依据”选项,然后按照前面的讨论选择颜色。 对于最低值,我们将分配红色,最高值的颜色将为蓝色 。 完成后单击确定

    Figure 13 – Defining Color Scale

    图13 –定义色阶

  7. You’ll now see that the matrix has been highlighted with the colors as selected in the step above:

    现在,您将看到矩阵已用上面步骤中选择的颜色突出显示:

    Figure 14 – Conditional Formatting Applied

    图14 –应用条件格式

  8. It is now easy to identify which are the lowest and highest values in the entire matrix just by looking at the saturation of the background colors. The highest being “1,39,07,567.18” and the lowest is “3,30,234.52”:

    现在,仅通过查看背景色的饱和度即可轻松确定整个矩阵中的最低值和最高值。 最高的是“ 1,39,07,567.18 ”,最低的是“ 3,30,234.52 ”:

    Figure 15 – Highest and Lowest Values

    图15 –最高和最低价值

Now that we have seen what conditional formatting in Power BI is all about, let us explore some more different ways of implementing the same. In the steps above, the formatting rule is based on the range of cell values. That means, depending on the value a cell holds, the saturation of the background color changes. However, there might be scenarios where you’d like to visualize the formatting based on a fixed number value and don’t want to change the saturation of the colors. Or you might also want to segregate the measures into categories like High, Average and Low values.

现在,我们已经了解了Power BI中的条件格式是什么,让我们探索实现相同条件的更多不同方法。 在上述步骤中,格式化规则基于单元格值的范围。 这意味着,根据单元格保持的值,背景色的饱和度会发生变化。 但是,在某些情况下,您可能想根据固定的数值可视化格式,并且不想更改颜色的饱和度。 或者,您可能还想将度量分为平均低值等类别。

In the steps below, we will try to modify the rules of the conditional formatting from range to fixed values.

在下面的步骤中,我们将尝试将条件格式的规则从范围修改为固定值。

  1. Right-click on the “Total Including Tax” field in the Values section
  2. 右键单击“ 值”部分中的“ 含税总额 ”字段
  3. Conditional Formatting and then click on the 条件格式 ,然后单击Background color 背景色
  4. Format button and turn on the 格式”按钮,然后在“ Background Color under 条件格式”下打开“ Conditional Formatting 背景色
  5. The Background Color – Formatting dialog box opens “背景色-格式设置”对话框打开
  6. In the Format By dropdown, select Rules

    格式依据下拉列表中,选择规则

    Figure 16 – Selecting Rules

    图16 –选择规则

  7. New Rule button 新建规则”按钮创建尽可能多的规则
  8. Click OK once done

    完成后单击确定

    Figure 17 – Defining Colors

    图17 –定义颜色

  9. You can see that the formatting for the matrix has been updated. Now we have three different colors that tell us under which category each of the cell values lies

    您可以看到矩阵的格式已更新。 现在,我们用三种不同的颜色告诉我们每个单元格值位于哪个类别下

    Figure 18 – Rule-Based Conditional Formatting

    图18 –基于规则的条件格式

Thus, in the above exercise, we have seen how we can implement conditional formatting in Power BI based on two different ways. The first one was by using the Color Scale and the second was by defining specific Rules for the formatting.

因此,在上面的练习中,我们已经看到了如何基于两种不同的方式在Power BI中实现条件格式。 第一个是通过使用色阶 ,第二个是通过定义格式的特定规则

Power BI中带有图标的条件格式 (Conditional formatting with icons in Power BI)

Let us now go one step further and implement some icons just as a visual indicator in the cells. These specific icons are helpful when defining any KPIs, or while comparing metrics based on a criterion. You can follow the steps mentioned below to implement the icons in the cells.

现在让我们更进一步,实现一些图标,作为单元格中的可视指示器。 这些特定图标在定义任何KPI或基于标准比较指标时很有用。 您可以按照下面提到的步骤在单元格中实现图标。

  1. Right-click on the “Total Including Tax” field in the Values section
  2. 右键单击“ 值”部分中的“ 含税总额 ”字段
  3. Select Conditional Formatting and then click on Icons

    选择条件格式 ,然后单击图标

    Figure 19 – Selecting Icons

    图19 –选择图标

  4. Icons – Formatting dialog box opens 图标 -格式对话框打开
  5. Format By option be as 格式依据”选项作为Rules 规则
  6. Select Icon Layout as Right of Data and Icon Alignment as Middle
  7. 选择“ 图标布局”作为数据权限,选择“ 图标 对齐”作为中间
  8. Select any option from the dropdown menu for Style and click OK

    样式的下拉菜单中选择任何选项,然后单击确定

    Figure 20 – Defining Rules for Icons

    图20 –定义图标规则

  9. Now you can see that the matrix displays additional icons based on the conditions that are defined in the previous step

    现在您可以看到矩阵根据上一步中定义的条件显示了其他图标

    Figure 21 – Conditional Formatting with Icons

    图21 –带图标的条件格式

  10. This is an important feature that helps users to visually understand if the metric has performed well or not 这是一项重要功能,可以帮助用户直观地了解指标是否​​执行良好
  11. Again, you can add as many rules as required based on the requirements 同样,您可以根据需求添加任意数量的规则

结论 (Conclusion)

In this article, I have explained what conditional formatting in Power BI is all about and how to implement the same. I have also explained the different ways in how conditional formatting can be applied and in what scenarios. Finally, we have seen how to include some infographic visuals (icons) in the visuals that help increase the readability of the reports to a great extent.

在本文中,我解释了Power BI中的条件格式是什么以及如何实现相同的条件。 我还解释了如何应用条件格式以及在哪种情况下使用不同的方法。 最后,我们已经看到了如何在视觉效果中包含一些图表视觉效果(图标),从而在很大程度上帮助提高报告的可读性。

翻译自: https://www.sqlshack.com/conditional-formatting-in-power-bi-2/

power bi条件格式

power bi条件格式_Power BI中的条件格式相关推荐

  1. android 视频转字节,如何将视频文件(.mp4)格式转换为android中的二进制格式?...

    我想在网络服务器上传视频.我得到了我想要以二进制格式传递文件的服务,我该怎么做?如何将视频文件(.mp4)格式转换为android中的二进制格式? 我试图通过base64将视频文件转换为二进制格式.. ...

  2. power bi 背景图_Power BI桌面饼图树

    power bi 背景图 Power BI Desktop amplifies the value of data. We can connect to multiple data sources a ...

  3. power bi 背景图_Power BI桌面脉冲图

    power bi 背景图 In my last article, Power BI Desktop Interactive chord diagrams, we underscored that Mi ...

  4. hive 导出json格式 文件_hive中创建hive-json格式的表及查询

    在hive中对于json的数据格式,可以使用get_json_object或json_tuple先解析然后查询. 也可以直接在hive中创建json格式的表结构,这样就可以直接查询,实战如下(hive ...

  5. mysql 查询总数时条件_SQL查询数据库中符合条件的记录的总数

    1. select count(*) from table; //统计元组个数 2. select count(列名) from table; //统计一列中值的个数 3. select count( ...

  6. outlook html格式 效果,outlook中以html格式回复邮件

    默认都是html或rtf格式,但一旦有人以txt格式回复了一下,整个格式就乱了,非常的难读.(除非大家都是txt格式写出来的,讲究排版,我只在linux下的mutt里这么干) outlook似乎没有配 ...

  7. power bi示例文件_Power BI桌面问答数据交互示例

    power bi示例文件 The Q&A feature in Power BI desktop provides a way to move towards Artificial Intel ...

  8. 语言 全排列 函数_Power Query 中日期时间格式转换需要了解的区域语言对照表

    不同的国家有不同的日期时间书写格式,比如: 多数亚洲国家:yyyy-MM-dd hh:mm 有些欧洲国家:dd.MM.yyyy HH:mm 极少数的国家:MM/dd/yyyy h:mm tt 还有各种 ...

  9. c语言条件语句示例_PHP中的条件语句和示例

    c语言条件语句示例 PHP条件语句 (PHP Conditional Statements) While coding, you may get to a point where your resul ...

  10. mysql left join中on后加条件判断和where中加条件的区别

    left join中关于where和on条件的几个知识点:1.多表left join是会生成一张临时表,并返回给用户2.where条件是针对最后生成的这张临时表进行过滤,过滤掉不符合where条件的记 ...

最新文章

  1. 如何用技术搞好英俄翻译?
  2. 北斗部标808协议解析说明示例
  3. 2.3.3 进程互斥的硬件实现方法
  4. Thrall’s Dream HRBUST - 2048【BFS or 强连通分量】
  5. 自动调试自动编译五分钟上手
  6. 【腾讯Bugly干货分享】彻底弄懂 Http 缓存机制 - 基于缓存策略三要素分解法
  7. 语音识别如何识别中英混杂的语句?或者别的不同语言混合的语句?
  8. 泛型与继承的关系,通配符
  9. mysql的逻辑备份和恢复
  10. 向日葵,teamviewer
  11. wikisql 数据集解释_【wiki维基百科中文数据集】抽取wiki数据集——实操
  12. 游戏是怎么赚钱的 - 聊聊山寨与混搭
  13. XXL之整合SpringBoot
  14. 协同开发 ----以码云为例
  15. 用计算机怎么计算字节,计算机硬盘容量大小怎么计算
  16. #2021暑假杭电多校8_1003.Ink on paper
  17. 计算机应用的知识能力和素质,信息素质与计算机应用能力
  18. lap 加MySQL主从复制_LAP+mysql-主从+redis
  19. maven之插件仓库
  20. 月薪80k阿里架构师:给迷茫的JAVA一些中肯建议(附学习路线图)

热门文章

  1. 苹果税务信息填写教程
  2. 龙芯电脑上架设网络学习管理系统Moodle
  3. HDU 5745 La Vie en rose (DP||模拟) 2016杭电多校联合第二场
  4. 微信H5生成海报图片并保存到手机
  5. java基础-对15位或18位身份证号码的验证
  6. ESP车身电子稳定系统
  7. excel一列求和_excel中使用函数实现自动求和
  8. Ant 下载安装配置使用教程
  9. 乔治城大学计算机科学专业,[转载]美国西北大学计算机科学研究生最新专业排名...
  10. 第三部分 数据结构 -- 第二章 队列-1362:家庭问题(family)