Forum Discussion

CameronRae's avatar
CameronRae
New Member
2 years ago

Using the Vega-Lite Impute Statement within Deneb

Hi Everyone,

 

I’ve recently started learning how to work with Vega-Lite.  

 

I’m looking to produce a form of academic calendar visualisation through Power BI/Deneb (with rows per term and columns per week). As the data is quite sparse, I opted to use Vega-Lite transform statements such as ‘impute’ to fill in gaps in the data.

 

Although the specification works as expected within the Vega-Lite online editor environment (see simplified code sample below), the equivalent specification doesn’t fully work within Deneb. There don’t appear to be any errors or warnings, but the ‘impute’ statements don’t seem to have any effect.

 

Is it possible to use the ‘impute’ statement to add records to a Deneb ‘dataset’? If not, is there an alternative/better way to achieve the desired outcome?

 

Thanks in advance

 

Simplified Vega-Lite specification…

 

{

  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",

  "data": {

  "values": [

       {"Term": "Term 1", "Week No": "Wk. 1", "Description": "Lesson 1",  "Attendance": 1, "Attendance Text": "Attended"},

       {"Term": "Term 1", "Week No": "Wk. 5", "Description": "Lesson 2",  "Attendance": 3, "Attendance Text": "Unauthorised Absence"},

       {"Term": "Term 2", "Week No": "Wk. 2", "Description": "Lesson 3",  "Attendance": 1, "Attendance Text": "Attended"},

       {"Term": "Term 2", "Week No": "Wk. 6", "Description": "Lesson 4",  "Attendance": 2, "Attendance Text": "Authorised Absence"},

       {"Term": "Term 3", "Week No": "Wk. 7", "Description": "Lesson 6",  "Attendance": 0, "Attendance Text": "Future Event"}

      ]

    },

    "transform": [

      {

       "impute": "Attendance Text",

       "key": "Term",

       "keyvals": ["Term 1", "Term 2", "Term 3"],

       "value": "No Event"

     },  

     {

      "impute": "Attendance Text",

      "key": "Week No",

      "keyvals": ["Wk. 1", "Wk. 2", "Wk. 3", "Wk. 4", "Wk. 5", "Wk. 6", "Wk. 7", "Wk. 8"],

      "value": "No Event",

      "groupby": ["Term"]

    }

    ],

    "mark": "rect",

    "encoding": {

      "x": {"field": "Week No"},

      "y": {"field": "Term"},

      "color": {"field": "Attendance Text"}

    }

}

 

Sample output…

 

 

3 Replies

    • dm-p's avatar
      dm-p
      Super User

      lbendlin - Deneb uses the Vega-Lite parser, so it's supported. It seems to work as I would expect if I take the sample spec and create a visual with it: