-
PQ - Evaluate
| Equation |
Evaluate |
| 1+2 |
3 |
| 125x12 |
1500 |
| 12x3-99 |
-63 |
| 22:7 |
3.142857143 |
| 125x(5+7:2) |
1062.5 |
| 34:(9x0.6-3)^3 |
2843.171296 |
| 3^(34:(9x0.6-3)) |
5744044.228 |
| 2^7 |
128 |
| 7^0 |
1 |
| 5-"" |
check the syntax |
| 2:0 |
check the syntax |
| Ax9 |
check the syntax |
| 3=2 |
FALSE |
| 3<>2 |
TRUE |
| 5:0.+3 |
check the syntax |
| 5:0x4 |
check the syntax |
| 0^7 |
0 |
| 0.59x3.21:0.5:0 |
check the syntax |
| 5x(3+2 |
check the syntax |
| 6^ |
check the syntax |
| 2^-3 |
0.125 |
| 27^1/3 |
3 |
| 2^(1/2) |
1.414213562 |
| 3^(1/2) |
1.732050808 |
| 10^(1/10) |
1.258925412 |
| Ln(10) |
2.302585093 |
| Log(2) |
0.693147181 |
Code:
// Evaluate
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Null = Table.SelectRows(Source, each ([Equation] <> null)),
RepColon = Table.ReplaceValue(Null,":","/",Replacer.ReplaceText,{"Equation"}),
RepAsterisk = Table.ReplaceValue(RepColon,"x","*",Replacer.ReplaceText,{"Equation"}),
EE = Table.AddColumn(RepAsterisk, "Evaluate", each try if Text.Contains([Equation], "/0") or Text.Contains([Equation], "/0.") then "check the syntax" else if Text.Contains([Equation], "Log") then Number.Log(Number.From(Text.BetweenDelimiters([Equation], "(", ")"))) else if Text.Contains([Equation], "Ln") then Number.Ln(Number.From(Text.BetweenDelimiters([Equation], "(", ")"))) else if Text.Contains([Equation], "^") then Number.Power(Expression.Evaluate(Text.BeforeDelimiter([Equation], "^")), Expression.Evaluate(Text.AfterDelimiter([Equation], "^"))) else Expression.Evaluate([Equation]) otherwise "check the syntax"),
TSC = Table.SelectColumns(EE,{"Evaluate"})
in
TSC