Forum Discussion
Divide formula in power query
- Anonymous2 years ago
Hi juhoneyighot ,
The Error: Divide by zero error encountered means the divisor you are using, i.e. column msdyn_plannedsales, has a value of 0 or a null value. And in math calculations the divisor can't be 0.
Here is my sample data:Please change the M function into this:
if [plannedsales] = 0 or [plannedsales] = null then "There is no plannedsales" else [actualsales] / [plannedsales]You can change the content of "xxx" by yourself.
And the final output is as below:
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi juhoneyighot ,
audreygerred Thanks for your concern about this case!
And juhoneyighot , the two screenshots you put up are the same, what exactly is the Error you are experiencing? Can you resubmit the screenshots?
In addition, your M function has been tested and there is no problem itself, so there may be a problem with the structure of your data, if you can please provide a sample data, thank you!
Best Regards,
Dino Tao
- juhoneyighot2 years agoHelper III
Anonymous
I'm sorry for that. Here is the error.
- Anonymous2 years agoNot applicable
Hi juhoneyighot ,
The Error: Divide by zero error encountered means the divisor you are using, i.e. column msdyn_plannedsales, has a value of 0 or a null value. And in math calculations the divisor can't be 0.
Here is my sample data:Please change the M function into this:
if [plannedsales] = 0 or [plannedsales] = null then "There is no plannedsales" else [actualsales] / [plannedsales]You can change the content of "xxx" by yourself.
And the final output is as below:
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.