Deneb Example - Population Pyramid

Deneb/Vega-Lite can be used to create a population pyramid visual in Power BI. The example visual presented herein consists of 3 parts: a left-facing bar chart, a right-facing bar chart, and a common Y-axis. A standard Power BI shape map (inset) is also included for context.

This example illustrates a number of Deneb/Vega-Lite features, including:
0 - General:

  • use of a “transform” block to filter the dataset and extend the dataset with an in-visual calculated (modified) age group name
  • use of an “hconcat” block consisting of 3 sections: bar (female), text (axis), and bar (male).

1 - Female:

  • use of a “layer” block with 3 overlapping marks - 2x text (province name, province total population) and 1x bar (female count by age group)
  • use of a “transform” block to filter the dataset (for female) and extend the dataset with an in-visual calculated inverted (*-1) count value
  • use of a “bar” mark with rounded corners and single-colour gradient (20% opacity to 80% opacity)
  • use of the negative count value to reverse the bar direction and the positive count value for the X-axis
  • use of D3 formatting to show SI values (in this case, thousands) on the X-axis (zero value suppressed)
  • use of a custom tooltip with Power BI formatting

2 - Y-Axis:

  • use of a “text” mark to display the (modified) age group name

3 - Male:

  • use of a “transform” block to filter the dataset (for male)
  • use of a “bar” mark with rounded corners and single-colour gradient (20% opacity to 80% opacity)
  • use of D3 formatting to show SI values (in this case, thousands) on the X-axis (zero value suppressed)
  • use of a custom tooltip with Power BI formatting

The intent of this example is not to provide a finished visual, but rather to serve as a starting point for further custom visual development.

Also included is the sample PBIX using a dataset derived from the public data published by the Canadian government for the most-recent census [2021].

This example is provided as-is for information purposes only, and its use is solely at the discretion of the end user; no responsibility is assumed by the author.

Greg
Deneb Examples - Population Pyramid.pbix (66.9 KB)

7 Likes

marking as solved