Does Looker have a Table Calc equivalent to R's pnorm() and qnorm() functions?

Knowledge Drop

Last tested: Jan 21, 2019

According to the R documentation (from inputting >?pnorm in R Studio), pnorm can take up to 5 arguments. This takes a Z-score value q and outputs a probability or p-value.
pnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)

The related function in Looker's Table Calculations is 
norm_dist() which is described as: 
norm_dist(value, mean, stdev, cumulative)

Returns the position of value on the normal distribution with the given mean and stdev. If cumulative = yes, then returns the cumulative probability"

Translating this to R language (with the exception of the log.p functionality, which could be achieved by taking the log of the resulting p-value in Looker) 
value = q
mean = mean
stdev = sd
cumulative = lower.tail 
If cumulative is "yes" or lower.tail is "TRUE" then our p-value is P[X<=x].

To give an example, we get the following in R:
> pnorm(2, 0, 1)
[1] 0.9772499

Which is similarly achieved in Looker using:
norm_dist(2,0,1, yes) which gives us 0.977249868 in the calculation column.


The equivalent to qnorm is the norm_s_inv() function in Table Calculations. Like qnorm, we can input a lower-tail p-value into norm_s_inv() and receive the Z-score for that p-value. It is worth noting that qnorm in R can take up to 5 arguments, like pnorm. In Looker, norm_s_inv() only takes a single p-value, nothing else.

in R:
> qnorm(0.025)
[1] -1.959964

in Looker: 
norm_s_inv(0.025) which gives us
-1.95996398 in the calculation column.

This content is subject to limited support.                

Version history
Last update:
‎05-07-2021 09:01 AM
Updated by: