简体   繁体   English

Deneb & PowerBI:风险矩阵项目

[英]Deneb & PowerBI: Risk matrix Project

I am currently working on a risk matrix in PowerBI which I want to create with Deneb.我目前正在研究我想用 Deneb 创建的 PowerBI 中的风险矩阵。 The goal is a 3x3 matrix that allows cross-filtering.目标是允许交叉过滤的 3x3 矩阵。 David already gave create support regarding the Vega lite code, however, some PowerBI specific questions remain. David已经就 Vega lite 代码提供了创建支持,但是,仍然存在一些 PowerBI 特定问题。 My current progress can be seen here: PowerBi File .我目前的进度可以在这里看到: PowerBi File

Now I face the following challenges, which I am grateful for any help in overcoming:现在我面临以下挑战,感谢任何帮助我克服这些挑战:

  • The selected cell should be highlighted (see sheet 2 as an example).选定的单元格应突出显示(参见表 2 作为示例)。 As an alternative it would be nice if at least the selected number can be highlighted.作为替代方案,如果至少可以突出显示所选数字,那就太好了。 With "__ selected __" I unfortunately did not reach the objective.不幸的是,“__选择了__”我没有达到目标。

  • It would be nice if a 0 appeared in the empty field.如果 0 出现在空白字段中,那就太好了。

  • There should be a space between each cell comparable to the one on page 2.每个单元格之间应该有一个与第 2 页相当的空格。

As always, I appreciate any solutions, hints or ideas.与往常一样,我感谢任何解决方案、提示或想法。 :) :)

OK, follow these steps to have a fully working and interactive risk matrix like the one below.好的,按照这些步骤来获得一个完全有效的交互式风险矩阵,如下所示。 在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

  1. Create a Damage dimension table as follows创建损坏维度表如下

在此处输入图像描述

  1. Create an Exposure dimension table as follows:创建一个 Exposure 维度表,如下所示:

在此处输入图像描述

  1. Create two relationships to your fact table as follows.如下创建与事实表的两个关系。

在此处输入图像描述

  1. Create a measure as follows如下创建度量

    Risk Count = COUNTROWS(Sheet1) +0风险计数 = COUNTROWS(Sheet1) +0

  2. Create a new Deneb visual adding the two dimensions and the measure (make sure not to aggregate)创建一个新的 Deneb 视觉对象,添加两个维度和度量(确保不要聚合)

在此处输入图像描述

  1. Place this code inside Deneb将此代码放在天津四内
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {"name": "dataset"},
  "width": 500,
  "height": 500,
  "encoding": {
    "y": {
      "field": "Exposure",
      "type": "ordinal",
      "sort": ["high", "medium", "low"]
    },
    "x": {
      "field": "Damage",
      "type": "ordinal",
      "sort": ["low", "medium", "high"],
      "axis": {"labelAngle": 0}
    }
  },
  "layer": [
    {
      "encoding": {
        "opacity": {
          "condition": {
            "test": {"field": "__selected__", "equal": "off"},
            "value": 0.3
          }
        }
      },
      "mark": {
        "type": "rect",
        "color": {
          "expr": "(datum['Exposure'] == 'high' & datum['Damage'] == 'high') || (datum['Exposure'] == 'high' & datum['Damage'] == 'medium') || (datum['Exposure'] == 'medium' & datum['Damage'] == 'high') ? 'red' : (datum['Exposure'] == 'medium' & datum['Damage'] == 'medium') || (datum['Exposure'] == 'high' & datum['Damage'] == 'low') || (datum['Exposure'] == 'low' & datum['Damage'] == 'high') ? 'orange': 'green'"
        }
      }
    },
    {
      "mark": {
        "type": "text",
        "fontSize": 16,
        "fontWeight": "bold",
        "color": "white"
      },
      "encoding": {"text": {"field": "Risk Count", "type": "quantitative"}}
    }
  ],
  "config": {"axis": {"grid": true, "tickBand": "extent"}}
}

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

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