The M code does not work as I want to (Simple)

Hi DNA Team,

I’ve stuck on something tiny but I don’t understand why the formula does not work as I want to.
Debit Credit.xlsx (18.0 KB)

The attached file data contains 3 rows in query editor I would like to add 4th column call Amount

I tried to write if statement if Debit > 0 then Debit else -1 * Credit but I didn’t get the correct result.

I will appreciate your help.

I would like to have Values of Debit and Credit in one Column whereas Credit needs to be negative.

Hi @Matty

I checked your file and saw that you have null in rows as value.Just changed null to 0 for both credit and debit column and you are good to go.
Debit Credit.xlsx (18.0 KB)

Hope this helps.

Regards,
Hemant

Thank you @Hemantsingh,

I thought when I converted a table to number the empty cell will be treated as 0 but I was wrong :slight_smile:

Hey @Matty

If my solution has solved your issue than accept it as solution for others in the community.

Regards,
Hemant