Skip to content

Instantly share code, notes, and snippets.

@ncalm
Created August 2, 2023 16:05
Show Gist options
  • Save ncalm/93ea267c9305a7a0256e62f9f4b3d66b to your computer and use it in GitHub Desktop.
Save ncalm/93ea267c9305a7a0256e62f9f4b3d66b to your computer and use it in GitHub Desktop.
This Excel LAMBDA function calculates the coordinates for two series to add to a scatterplot to produce a vertical and horizontal line
chart.Quadrants = LAMBDA(seriesData,
LET(
// The first column (x values)
x, TAKE(seriesData, , 1),
// The second column (y values)
y, TAKE(seriesData, , -1),
xMax, MAX(x),
yMax, MAX(y),
// Assuming we want lines as close to the "middle" as possible
xMid, INT(xMax / 2),
yMid, INT(yMax / 2),
// To make the use of HSTACK shorter - that's all!
H, LAMBDA(one, two, HSTACK(one, two)),
// Create the coordinates of the beginning and end of each line
H(
{"Vertical Line"; ""; "Horizontal Line"; ""},
VSTACK(H(xMid, 0), H(xMid, yMax), H(0, yMid), H(xMax, yMid))
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment