JAVASCRIPT for number twister

Hey guys, I am trying to find number twister in my amount column and I tried herefore a javascript but unfortunately it is not working - maybe u can help me:

function numberCruncherComparison(numberList, toCompare){
for (const element of numberList) {
if (toCompare[0] === ‘-’) {
if (toCompare.length < 3) {
return false;
}

        if (element[0] === '-') {
            if (element[1] === toCompare[2] && element[2] === toCompare[1]) {
                return true;
            }
        }
    } else if (toCompare.length < 2) {
            return false;
        }
     if (element[0] === toCompare[1] && element[1] === toCompare[0]) {
        return true;
    }
}
return false;

}

I don’t understand what you mean by ‘number twister’ or what you are trying to do.

Perhaps you could explain in terms of the input you have and the output you want, with an example.

Hi , i am trying to find number twister-or type errors. For example the amount is 96, but the user types 69 - this i tried out to find with javascript or is there a better way to do it?

If you are expecting 96, but the data is 69, then that isn’t a type error. They are both numbers. Also I am not familiar with the term ‘number twister’. So I am still struggling to understand what you are trying to do.

It would be helpful if you could supply a simple input dataset and the corresponding output dataset you want.

okay i understand now the issue. - here is an example - i want to find similiar numbers in my whole dataset

So how are you deciding which values are true or false? Are you comparing it to another column of data?

i am comparing the value - in the amount column - so if the values are identical but in other order then i flag it

To what? Sorry if I am being a bit thick here.

for example i am an accountant-i have done two bookings for the same receipt - but i have not realized it because i had an type error

So why is ‘42’ and ‘24’ are true because they are reverse orderings of each other?

yes, exactly thats is the reason

I believe this does what you want:

reverse-match.transform (5.2 KB)

The Javascript transform is only necessary to reverse the values.

We also have a ‘fuzzy’ Dedupe function. But it won’t be much use in this situation.

great :slight_smile: thanks a lot - really smart way to solve it

1 Like

Here you go.

image

Transform File.
CheckNumberTwister.transform (2.9 KB)

2 Likes

thanks mate :slight_smile: that is brilliant

1 Like

Hi Mate, do you know if i can find for example a number twister for example my dataset has: 1250 and 1205 (this one i would like to find) but i dont have 5021 now it works only for the complete number when it is twisted , but in reality the type error are only two numbers for example

Here is revised solution as per your need, to look for reversed only last two number, in addition to whole reverse number.

Transform file.
CheckNumberTwister2.transform (4.9 KB)

2 Likes