Hi,
It looks like the formula is intended to calculate variance/growth between two values with some added logic for errors, negative values and results over 999. If my assumption is correct then I think your formula is missing two things:
- an asterisk between F6 and 100
- the (1) should be (-1)
For Excel:
In Excel, you can use a SWITCH(TRUE()...) pattern instead of nested if statements and wrap that in an IFERROR. This might make it easier for you to read/interpret.
Excel Formula
=
IFERROR(
SWITCH(
TRUE(),
(G6-F6)/F6*100 > 999, "",
(G6-F6)/F6*100 < -999, "",
AND(G6>0,F6>0), (G6-F6)/F6*100,
((G6-F6)/F6*100)*(-1)),
"")
For Power Query:
In PQ, write the if/else statements and wrap them in a try/otherwise for the error handling.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUs7TT1TSUTI1UIrViVYywc40RbB1kTlgti6KDJgXCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value1 = _t, Value2 = _t]),
PreviousStep = Table.TransformColumnTypes(Source,{{"Value1", type number}, {"Value2", type number}}),
AddCol = Table.AddColumn(PreviousStep, "Result", each try
if ([Value2]-[Value1])/[Value1]*100 > 999 then "" else
if ([Value2]-[Value1])/[Value1]*100 < -999 then "" else
if ([Value1]>0 and [Value2]>0) then ([Value2]-[Value1])/[Value1]*100 else
(([Value2]-[Value1])/[Value1]*100)*(-1) otherwise "", type number)
in
AddCol