I have a dataset where each row contains two integer values which represent a ratio. For each row, I want to "simplify" the ratio between these two numbers.
For example, if the two numbers are 20 and 10, the ratio 20:10 can be simplified to 2:1
Other examples:
2:2, 3:3, 27:27 are all simplified to 1:1
14:18 is simplified to 7:9
The way I am approaching this is to find the Highest Common Factor between the two numbers. Then I can divide both numbers by this HCF.
Using that last example again, the HCF of 14 & 18 is 2. Dividing both numbers by 2 gives me the desired values 7 & 9.
To find the HCF, I am attempting to implement Euclid's Algorithm. lets call the two numbers to be factored "A" and "B"
Step 1: sort them so that A is the higher value
Step 2: C = Mod(A, 
Step 3. If C is zero, then we have found the HCF and its value is B. End of algorithm
Step 4. If C is not zero, then replace A with B and B with C and go back to step 2
Using the same example of 14 & 18:
Iteration 1:
A = 18
B = 14
C = Mod(18, 14) = 4
Iteration 2:
A = 14
B = 4
C = Mod(14, 4) = 2
Iteration 3:
A = 4
B = 2
C = Mod(4, 2) = 0
No more iterations required, HCF of 14 & 18 was the last value of B which was 2.
Here is my attempted Alteryx flow. Unfortunately, as you can see from the error message, the way I am trying to do this is obviously an abuse if the Union tool!
Can the forum members please suggest a simple approach to this problem?