Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
centroid
Helper I
Helper I

Custom Report, displaying general quantiles in bar chart style instead of boxplot

Hi,

I would like to create a general quantile report in a bar chart style. I am not sure how to this. See my below example. I did not find any downloable custom charts for this. My underlying dataset is organized as follows. In my dataset there are N locations (classes if you want) and for each location (or class) a large number of observations which should be put into the respective quantiles. The reason why I want to avoid boxplot is that the resulting report should be included in a publication to the general public, i.e. to non-statisticians, for marketing purposes.  Custom quantiles should be used instead of quartiles as well. How can I do this most efficiently?
Box-and-Whisker-Plot-Example-1-17.png

4 REPLIES 4
ppm1
Solution Sage
Solution Sage

This can be done with the Deneb visual. I did a quick POC but much more could be done to pretty it up. You should be able to take the code below, put it in the visual and edit the field mapping (to switch it to your data).

Declarative Visualization in Power BI | Deneb

 

ppm1_0-1679238028032.png

 

{
  "data": {"name": "dataset"},
  "transform": [
    {
      "aggregate": [
        {
          "op": "min",
          "field": "Total Sales",
          "as": "Min"
        },
        {
          "op": "max",
          "field": "Total Sales",
          "as": "Max"
        },
        {
          "op": "median",
          "field": "Total Sales",
          "as": "Median"
        },
        {
          "op": "q1",
          "field": "Total Sales",
          "as": "Q1"
        },
        {
          "op": "q3",
          "field": "Total Sales",
          "as": "Q3"
        }
      ],
      "groupby": ["Subcategory"]
    }
  ],
  "layer": [
    {
      "mark": {
        "type": "bar",
        "color": "red"
      },
      "encoding": {
        "y": {
          "field": "Min",
          "type": "quantitative"
        },
        "y2": {"field": "Q1"}
      }
    },
    {
      "mark": {
        "type": "bar",
        "color": "blue"
      },
      "encoding": {
        "y": {
          "field": "Q1",
          "type": "quantitative"
        },
        "y2": {"field": "Median"}
      }
    },
    {
      "mark": {
        "type": "bar",
        "color": "green"
      },
      "encoding": {
        "y": {
          "field": "Median",
          "type": "quantitative"
        },
        "y2": {"field": "Q3"}
      }
    },
    {
      "mark": {
        "type": "bar",
        "color": "yellow"
      },
      "encoding": {
        "y": {
          "field": "Q3",
          "type": "quantitative"
        },
        "y2": {"field": "Max"}
      }
    }
  ],
  "encoding": {
    "x": {"field": "Subcategory"}
  }
}

Pat

 

Microsoft Employee

That looks good, but instead of the minimum value, the 25 % quantile, the median and the 75 % quantile and the maximum value, I should have the quantile boundaries 5 %, 25 %, 75 % and 95 %. How do I do this?

This page shows the available aggregations in Vega Lite (Deneb). If the ci0 and ci1 work for your 5 and 95%, you can easily adapt the earlier code with those instead. Otherwise, you would a DAX approach to get the 5 and 95 percentile.

 

Aggregation | Vega-Lite

 

Pat

Microsoft Employee

Look good, but what is meant by "the lower boundary of the bootstrapped 95% confidence interval of the mean field value."? Is there a methodological difference  to the calculation of the 25 % and 75 % quantiles? The term "bootstrapped" seems unclear to me, in this context.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.