streettree
streettree

Reputation: 11

How to insert custom values into VEGA Deneb Sankey Chart in PowerBI?

I'm trying to re-use the following code for my visualization: https://github.com/PBI-David/Deneb-Showcase/tree/main/Sankey%20Chart

This visualization is based on the input table, however, I'm struggling to replace the hardcoded values.

"data": [
    {
      "name": "input",
      "values": [
        {
          "category": "Total amount",
          "stack": 1,
          "sort": 1,
          "labels": "left"
        },
        {
          "category": "Product",
          "stack": 2,
          "sort": 1
        },
        {
          "category": "Service",
          "stack": 2,
          "sort": 2
        },
        {
          "category": "Visible",
          "stack": 3,
          "sort": 1
        },
        {
          "category": "under the radar",
          "stack": 3,
          "sort": 2
        },
        {
          "category": "No BOM",
          "stack": 3,
          "sort": 3
        },
        {
          "category": "No Opportunity ID",
          "stack": 3,
          "sort": 4
        },
        {
          "category": "Highway Robbery",
          "stack": 3,
          "sort": 5
        },
        {
          "source": "Total amount",
          "destination": "Product",
          "value": 20
        },
        {
          "source": "Total amount",
          "destination": "Service",
          "value": 1.9
        },
        {
          "source": "Product",
          "destination": "Visible",
          "value": 11.8
        },
        {
          "source": "Product",
          "destination": "under the radar",
          "value": 11.8
        },
        {
          "source": "Product",
          "destination": "No BOM",
          "value": 11.8
        },
        {
>           "source": "Product",
          "destination": "No Opportunity ID",
          "value": 11.8
        },
        {
          "source": "Product",
          "destination": "Highway Robbery",
          "value": 11.8
        }
      ]
    },

I have tried to reference the dataset from PowerBI directly, through signals, expressions and transforms in many different ways, however, I'm still stumped.

How could I populate these fields dynamically?

If you could point me in the right direction, I would be very thankful.

For example, when trying signals (even when setting them as the same value)

{
      "name": "SignalProductToVisible", 
      "value": 11.8
    }

(...)

{
          "source": "Product",
          "destination": "Visible",
          "value": {"signal": "SignalProductToVisible"}
        }

I get [Error] Invalid SVG path, incorrect parameter type, as it appears that the value is always undefined.

Upvotes: 1

Views: 498

Answers (1)

davidebacci
davidebacci

Reputation: 30219

Vega doesn't allow you to put signals in a data object like that. For the actual data, there are two appended tables in one. You need to supply a data table in Power BI in the following format (customised to your needs) for the first part.

enter image description here

The second part is as follows and must be appended by you to the first table in Power BI:

{
  "source": "Server Products & Cloud",
  "destination": "Intelligent Cloud",
  "value": 19.6
},
{
  "source": "Enterprise Services",
  "destination": "Intelligent Cloud",
  "value": 1.9
},
{
  "source": "Office Products",
  "destination": "Productivity",
  "value": 11.8
},
{
  "source": "LinkedIn",
  "destination": "Productivity",
  "value": 3.9
},
{
  "source": "Other",
  "destination": "Productivity",
  "value": 1.3
},

Everything else is calculated automatically downstream.

Upvotes: 0

Related Questions