The Lorenz curve is a graphical representation of the cumulative distribution of wealth, revenue, or operational output across a population. When paired with Pareto analysis, it visually contrasts actual distribution inequalities against a line of perfect equality, serving as the mathematical basis for deriving the Gini coefficient. Building a Lorenz curve model in traditional Excel required multi-step sorting, fragile manual formulas, and static helper columns. By orchestrating modern dynamic array functions including VSTACK, SCAN, and LAMBDA, you can build a self-contained Lorenz curve coordinate engine that updates dynamically.
Understanding Lorenz Curve Mathematical Architecture
A mathematically rigorous Lorenz curve maps cumulative population percentiles against cumulative metric percentiles:
- Horizontal Axis (Cumulative Population %): The cumulative share of sorted observations from 0% to 100%.
- Vertical Axis (Cumulative Value %): The cumulative share of total revenue or output generated by that population segment.
- Line of Perfect Equality: A diagonal 45-degree reference line where
Y = X(e.g., 50% of causes generate exactly 50% of consequences). - Origin Anchor (0, 0): The curve must strictly begin at
(0, 0)and terminate at(1, 1). - Gini Coefficient: Measures the area between the line of perfect equality and the Lorenz curve divided by the total area beneath the equality line.
Setting Up the Source Data Layout
Assume entity names (e.g., product lines or customer accounts) occupy column range A2:A100 and associated values reside in B2:B100:
- Ensure column B contains valid positive numbers.
- Select an adjacent cell (such as
D2) to host the dynamic array formula.
Constructing the Unified Dynamic Lorenz Formula
Enter the following comprehensive LET formula into cell D2 to generate the complete paired coordinates alongside equality baselines and headers:
=LET(
names, A2:A100,
values, B2:B100,
data, FILTER(HSTACK(names, values), ISNUMBER(values)),
val_sorted, SORT(CHOOSECOLS(data, 2), 1, 1),
n, ROWS(val_sorted),
total_val, SUM(val_sorted),
cum_pop, SEQUENCE(n) / n,
cum_val, SCAN(0, val_sorted, LAMBDA(acc,v, acc + v)) / total_val,
equality_line, cum_pop,
anchored_pop, VSTACK(0, cum_pop),
anchored_val, VSTACK(0, cum_val),
anchored_eq, VSTACK(0, equality_line),
table_body, HSTACK(anchored_pop, anchored_val, anchored_eq),
header, {"Cumulative Population (X)", "Lorenz Value (Y)", "Equality Baseline (Y=X)"},
VSTACK(header, table_body)
)
Formula Workflow and Logical Mechanics
This dynamic array pipeline processes coordinate calculations systematically:
- Ascending Sort (
SORT): Sorts observation values in ascending order (1). Lorenz curves require ordering from smallest contributor to largest contributor. - Cumulative Population Vector: Computes equidistant fractional increments using
SEQUENCE(n) / n, ensuring the X-axis spans smoothly from1/nto1.0. - Recursive Cumulative Aggregation (
SCAN): Progressively accumulates observation values, dividing bytotal_valto produce normalized cumulative shares. - Baseline Anchor (
VSTACK): Prepends coordinate0to all vectors, anchoring the origin at(0, 0). - Header and Matrix Assembly: Vertically joins descriptive column labels to the coordinate matrix.
Calculating the Gini Coefficient Dynamically
Calculate the Gini inequality coefficient using the trapezoidal approximation rule directly from the spilled coordinates in an adjacent cell:
=LET(
x, INDEX(D3#, 0, 1),
y, INDEX(D3#, 0, 2),
n, ROWS(x),
dx, DROP(x, 1) - DROP(x, -1),
y_avg, (DROP(y, 1) + DROP(y, -1)) / 2,
area_under_lorenz, SUM(dx * y_avg),
gini, (0.5 - area_under_lorenz) / 0.5,
gini
)
A Gini coefficient near 0 indicates near-perfect distribution equality; a coefficient approaching 1 reflects severe concentration.
Generating the Visual Lorenz Chart
To plot the Lorenz curve:
- Select the spilled coordinate columns (X, Lorenz Y, and Equality Y).
- Navigate to Insert > Scatter with Smooth Lines.
- Format both axes: set minimum bounds to
0.0, maximum bounds to1.0, and apply percentage number formatting. - Format the Equality Baseline as a dashed grey line. The bow shape of the solid Lorenz curve visually demonstrates your portfolio’s concentration profile.