简体   繁体   English

PowerBI-特定单元格的条件格式

[英]PowerBI - Conditional formatting of specific cells

This is what I have created on Excel: 这是我在Excel上创建的: 高强

I am trying to publish it on Power BI. 我试图将其发布在Power BI上。 I am struggling to find a setting to color specific cells according to what I have created in Excel. 我正在努力寻找一种根据我在Excel中创建的颜色对特定单元格进行设置的设置。 PowerBI

The conditional formatting guide ( https://powerbi.microsoft.com/en-us/documentation/powerbi-desktop-conditional-table-formatting/ ) suggests coloring the cells based on the value, but I want the colors to be static regardless of the values. 条件格式指南( https://powerbi.microsoft.com/zh-cn/documentation/powerbi-desktop-conditional-table-formatting/ )建议根据值为单元格着色,但是无论颜色如何,我都希望颜色是静态的值。

Question: How can I choose to color the cells according to my specific requirement? 问题:如何根据我的特定要求为电池着色?

What you're looking for is called Column Formatting in Power BI. 您要查找的内容在Power BI中称为列格式 You can find it in the format pane in Table or Matrix visualizations. 您可以在表格或矩阵可视化的格式窗格中找到它。

列格式

However, the best you can do is formatting per column level (and header / total), for font color and background color. 但是,最好的办法是针对字体颜色和背景颜色按列级别(和标题/总计)进行格式化。 Per cell level is not available in Power BI yet. 每个单元级别在Power BI中尚不可用。 You may consider submit a feature request to Power BI if you want to. 您可以根据需要考虑向Power BI提交功能请求

How can I choose to color the cells according to my specific requirement? 如何根据我的特定要求为电池着色?

There is an option to develop a custom visual with this behaviour. 有一个选项可以开发具有此行为的自定义视觉效果

There's a table visual template you can use as a start. 您可以使用表格视觉模板作为开始。

Thank you Foxan and user5226582. 谢谢Foxan和user5226582。 I am not sure if this answer is appropriate to SO's requirement for an answer, but in the end I did a hacky way of taking a screenshot of the colour without the values from Excel and inserted it as a background image to the table on PowerBI. 我不确定这个答案是否适合SO的要求,但是最后我做了一个很怪异的方法,可以在没有Excel值的情况下截取颜色的屏幕快照,并将其作为背景图像插入PowerBI的表格中。

For each cell you need to do the following: 对于每个单元格,您需要执行以下操作:

  1. extract 提取
    • column name, and 列名,以及
    • value in 1st column ( HI/CoF ($) ) of current row, 当前行第一列( HI / CoF($) )中的值,
  2. take the last symbol from both, 取两者的最后一个符号
  3. convert it to number and 将其转换为数字并
  4. check resulting values in conditional formatting to determine color. 检查条件格式中的结果值以确定颜色。

As an option, you may add both numbers and assign color according to the sum: 2 is green, 14 is red, other colors between. 作为一种选择,您可以将两个数字相加并根据总和分配颜色:2为绿色,14为红色,其间为其他颜色。 However, it probably wouldn't result in exactly same color matrix as is in your example. 但是,它可能不会产生与您的示例完全相同的颜色矩阵。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM