It’s possible to see that I’m trying to use another IF inside the true value.
I’m trying to reduce the IFs inside the rule, and trying the approach like Excel IF formulas.
Hi,
In JavaScript, which the Column Expression essentially is, you cannot use the if inline like you do here (and which works in Python). Instead, you can use the ternary operator:
Alternatively, you could first assign either column(“ICMS”) or column(“ICMS_ST”) to a separate variable based on a normal if, then use that variable inside your expression:
if (column("@CalculosPorFora") == "SIM" && column("CFOP_Ficha3") == "5405" && column("BC") == 1)
{
var icms = column("ICMS");
if (column("ICMS") <= 0) {
icms = column("ICMS_ST")
}
column("vProd")+column("vFrete")+column("vSeg")-column("vDesc")+column("vOutro") * icms
}
Hi,
It looks correct, but if your ifs do not match, then a missing value is returned. Can you make sure that your conditions are correct? You can also try removing conditions step-by-step and see when you get an output.
Kind regards,
Alexander
I always wanted to know if column expressions could do calculations with VAR statements, but I had never found anything on the forum. I use VAR in DAX PBI.
You solved my problem and taught me something new.
Very cool.
Thank you very much.