jitter chart in Power BI, jitter plot in Power BI, jitter small multiples in Power BI

Jitter chart in Power BI with average line by categories

Here is how to create a jitter chart in Power BI with averages by categories and using only Power BI and DAX capabilities. No custom visualizations are necessary. A jitter chart makes it easier to view overlapping data points by categories.

 

If you want to understand this technique in more detail, look at this post from this blog that contains an example in Excel. The main principle of creating a jitter plot is the same.

 

In this example, I’m using data from this data set that contains daily temperature measurements in New York from May to September 1973.

If you want to obtain that, you can use this M code in the blank query or download the pbix file with the result.
Here is my data and M code for that. The table name is air quality. I would like to visualize temperatures by month. The month name column is sorted by the column that contains the month number.

table in Power BI

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dVhbchsxDLvLfnc8EvU+S6b3v0YtgC+77Uc8iamlSBAgufn5eXp9fj31lPfnevX351zvj3G/fH7/+nnavL/W/f68P0vUKrDW+2ft537K6x5dXQ80HrgPtdrg5HW/n+ah48D7F7h43SNjqm3AJtut94Zp1knrfULOtWxcPYfaF6++Fphre11P46h9w76R+PVRXheEWdV8LLB6eji3h2uBeTG0icg86UrQ6n1CkM15rY+nFbeK2AsOSM6tKm7Xo8BvLcx+24keyE4+AhfDD4xw0VpP0HuYRBC2VhbjykEQQdQTMG1QYzg1iGC78TeRdIPHcCLP3gMHpw9RrEorWr1AUuPpJgURk13NThBHoDTCvZVQiGK71x3x/Nzs3EPK6tzTk2FmoZ38c4BlJurujydXUJOkx71uJm6dl0i43h6Z4cYkkS5SW4ZNI3Jt4TqwD8VZVrxWPfo9nb+oI5IJ63LgQDSQ1q1diEy1BK65uTT2dO5ue9hRFdSMF++h1gRqf1zyyAACI3JsJRHZFrUvfxwkoPC2BUZgF2VVH9c8JIZQidoBo1I7cg+qa1QGQVB2p5k9gBuh22PhqbDpulu79OirI9dASg1vW3jVsfvQk6OjmhZ26xrMWR7/TLxASd59DbX1GJScUO3yFKYVSFXNnk7VaRSOgbKT9F5EqRn5wB9HsQKlSbMFKQ4iMWaA/rCzDxl2Etet7bMA8+tmR7C2ofAv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D", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Ozone = _t, Solar.R = _t, Wind = _t, Temp = _t, Month = _t, Day = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Ozone", Int64.Type}, {"Solar.R", Int64.Type}, {"Wind", type text}, {"Temp", Int64.Type}, {"Month", Int64.Type}, {"Day", Int64.Type}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type",".",",",Replacer.ReplaceText,{"Wind"}),
    #"Year Column" = Table.AddColumn(#"Replaced Value", "Year", each 1973),
    #"MonthName Column" = Table.AddColumn(#"Year Column", "MonthName", each Date.MonthName(#date([Year], [Month], [Day]), "en-US")),
    #"Changed Type1" = Table.TransformColumnTypes(#"MonthName Column",{{"Wind", type number}, {"MonthName", type text}, {"Year", Int64.Type}})
in
    #"Changed Type1"

 

Jitter chart in Power BI

Usually, with the jitter chart, I will look at the modified scatter chart. At this moment, Power BI is not flexible enough. In my scenario, I would like to show Power BI jitter plots by month name category. I will use a line chart with only markers and small multiples.

Within each category, data points should be separated to avoid overlap. To do that, you can calculate jitter like this. You can divide jitter or multiply with a decimal number to acquire optimal dispersion. Try to provide a divisor by using the what-if parameter, like in this example.

Jitter = (RAND()-0.5)/3

jitter column in Power BI

The next step is to create a line chart with markers and remove the line (0 px stroke), x-axis content, and unnecessary elements.

line chart without line in Power BI, line chart with only markers in Power BI

Now add the category to the small multiples section, arrange small multiples in one row (you can do that by adjusting the column count that equals the category count), and do some formatting.

jitter plot in Power BI, jitter chart in Power BI

 

Average line by categories in Power BI

You might be happy with the jitter plot in Power BI as it is, but here is how to add additional measures by category. Here is how to create a measure of averages, ignoring the jitter within each category using the REMOVEFILTERS function.

Average Temperature =
CALCULATE ( AVERAGE ( airquality[Temp] ), REMOVEFILTERS ( airquality[Jitter] ) )

Add this to Y-axis values and format.

jitter chart in Power BI, jitter plot in Power BI, jitter small multiples in Power BI

If you want something more complex, try to use R script visuals. In this blog, you can find a couple of examples.
Here is a simple R jitter plot by categories, and here is another with additional measures.

Here is a jitter plot with the average line in Excel.


Posted

in

, ,

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *