Skip to content

Instantly share code, notes, and snippets.

@JonathanGawrych
Created February 17, 2020 00:58
Show Gist options
  • Select an option

  • Save JonathanGawrych/47af41f2d5b31af5ec7e7b94da46d975 to your computer and use it in GitHub Desktop.

Select an option

Save JonathanGawrych/47af41f2d5b31af5ec7e7b94da46d975 to your computer and use it in GitHub Desktop.
Do the chitest formula in memory. Assumes the data is in DATA!$A:$K, and that the chi sheet, the top/left row/column references the columns to use (B, C, D, etc)
=CHITEST(
QUERY(QUERY(Data!$A:$K,"SELECT count(B) WHERE "&$A2&" IS NOT NULL GROUP BY "&$A2&" PIVOT "&B$1, 1), "SELECT * OFFSET 1", 0),
MMULT(
QUERY(Data!$A:$K,"SELECT COUNT(B) WHERE "&$A2&" IS NOT NULL GROUP BY "&$A2&" label Count(B) ''", 1),
ARRAYFORMULA(DIVIDE(TRANSPOSE(
QUERY(Data!$A:$K,"SELECT COUNT(B) WHERE "&B$1&" IS NOT NULL GROUP BY "&B$1&" LABEL COUNT(B) ''", 1)),
QUERY(Data!$A:$K,"SELECT COUNT(B) LABEL COUNT(B) ''", 1)))
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment