Left and Right Justified Contiguous Bar Charts

Version 4

    Description:

     

    With the addition of the ability to specify the width of bars on a bar chart using a measure field it is possible to create contiguously filled bar charts. This can be accomplished with either left justification or right justification, using either a look ahead or look back table calculation.

     

     

    At the edges we have to set the left justified width to zero for the last point, and conversely the right justified width to zero at the first point.

     

    Example Calculation:

     

    // The left justified width sets the last width to zero,

    // and looks ahead to the next position.

    [LEFT] := IFNULL(LOOKUP(ATTR([ORDER]), 1), ATTR([ORDER])) - ATTR([ORDER])

     

    // The right justified width sets the first width to zero,

    // and looks back to the previous position.

    [RIGHT] := ATTR([ORDER]) - IFNULL(LOOKUP(ATTR([ORDER]), -1), ATTR([ORDER]))

     

    Inputs and Setup:

     

    The table calculations of the left and right widths require an continuous dimension as input, in this example the field is called [ORDER].

     

    Partitioning and Addressing:

     

    The table calculations of left and right widths must address the same field that determines the position, in this example the field is called [ORDER].


    Comments:

     

    The choice of whether to create contiguously filled bar charts with left or right justification is irrelevant in the asymptotic limit of large sample sizes, provided the actual sampling distribution has support across the whole domain.

     

    Related Functions:

     

    IFNULL, LOOKUP, ATTR, SIZE, INDEX

     

    Further Reading/Examples:

     

    The table calculation of the left and right justified widths is illustrated in the following worksheet.

     

    https://public.tableau.com/static/images/de/density-estimation/ParameterizedPercentilesandFullWidthHistorgrams/1.png

     

    The source code to generate the sample data is in a Jupyter notebook hosted on GitHub.