Last active
February 17, 2024 15:26
-
-
Save cbaragao/5a4241bbf7c57aeb25df22041f083376 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (val as number, col as list) => | |
| let | |
| l = List.Sort(col), | |
| count = List.Count(l), | |
| q1 = count * 0.25, | |
| q2 = count * 0.5, | |
| q3 = count * 0.75, | |
| fnRunCheck = (check as number)=> | |
| let | |
| get_q = if check = Number.IntegerDivide(check,1) then List.Average({l{Number.Round(check,0)-1}, l{Number.Round(check,0)}}) else l{Number.Round(check,0)} | |
| in | |
| get_q, | |
| q1_val = fnRunCheck(q1), | |
| q2_val = fnRunCheck(q2), | |
| q3_val = fnRunCheck(q3), | |
| iqr =q3_val - q1_val, | |
| return = [ | |
| quartile = if val <= q1_val then 1 else if val <= q2_val then 2 else if val <= q3_val then 3 else 4, | |
| q1= q1_val, | |
| q2 = q2_val, | |
| q3 = q3_val, | |
| interquartile_range = iqr, | |
| outlier = if val < q1_val - (1.5*iqr) then true else if val > q3_val + (1.5 * iqr) then true else false | |
| ] | |
| in | |
| return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment