Forum Discussion
Issue with Decimal Separator in DAX Formulas ( function SQRT)
- 2 years ago
Martin_2 , First of all check what value is this giving
(Pivot_Result[Average Lead time (Month)] * POWER(Pivot_Result[StdDeviation], 2)) +
POWER((Pivot_Result[Average / Month] * Pivot_Result[Average Lead time (Month)]), 2)and is that a number and falls in the range of SRT
if this part gives an error. means one of the value is not having correct data type
Martin_2 , First of all check what value is this giving
(Pivot_Result[Average Lead time (Month)] * POWER(Pivot_Result[StdDeviation], 2)) +
POWER((Pivot_Result[Average / Month] * Pivot_Result[Average Lead time (Month)]), 2)
and is that a number and falls in the range of SRT
if this part gives an error. means one of the value is not having correct data type
- Martin_22 years agoNew Member
Hello amitchandak / everyone,
I would like to apologize for any confusion caused by my previous post regarding an issue with decimal separators in DAX formulas. Upon further investigation, I discovered that there were indeed negative values in my data set which were causing the "SQRT" function to fail.
In my initial post, I had mistakenly assumed that all my inputs were positive numbers. However, after a more thorough review of my data, I found some negative values which were causing issues with the square root calculation.
Here is the updated formula that handles negative values correctly:
Safety_Stock = Pivot_Result[Coefficient service] *
SQRT(
IF(
((Pivot_Result[Average Lead time (Month)] * POWER(Pivot_Result[StdDeviation], 2)) +
(Pivot_Result[Average / Month] * POWER(Pivot_Result[Average Lead time (Month)], 2))) < 0,
0,
((Pivot_Result[Average Lead time (Month)] * POWER(Pivot_Result[StdDeviation], 2)) +
(Pivot_Result[Average / Month] * POWER(Pivot_Result[Average Lead time (Month)], 2)))
)
)This formula first calculates the expression inside the SQRT function and checks if it's less than zero. If it is, we replace it with zero; otherwise, we use the calculated value.
This ensures that we're not trying to take the square root of a negative number.
I hope this update clarifies the situation and I apologize for any misunderstanding.
Thank you all for your patience and assistance, 🙂
Martin