I have a simple function that is returning two different values in SQL and PowerBI.
Here is the equation:
1 - power(0.9240, exp((-0.2201*((71/10)-7.036))+(0.2467*(0-0.5642))-(0.5567*((60/5)-7.222))+(0.4510*(log(13.5)-5.137))))
in SQL:
SELECT 1 - power(0.9240, exp((-0.2201*((71/10)-7.036))+(0.2467*(0-0.5642))-(0.5567*((60/5)-7.222))+(0.4510*(log(13.5)-5.137))))
In SQL i get the correct value, 0.0015
but in PowerBI I get
0.0007783428
.
What do I need to change in my DAX expression so that it calculates the POWER() and EXP() and LOG() correctly?
I always recommend not doing technical translation from SQL to DAX so not to fall in similar situations.
WHat you have as a difference in the results can be due to the way each environment handles mathematical calculations, especially regarding the precision of floating-point operations and the implementation of the EXP(), POWER(), and LOG() functions.
Result =
1 - POWER(
0.9240,
EXP(
-0.2201 * ((71 / 10) - 7.036) +
0.2467 * (0 - 0.5642) -
0.5567 * ((60 / 5) - 7.222) +
0.4510 * (LN(13.5) - 5.137)
)
)