Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Re: Modulo (mod) Function: Not just for Evens and Odds

FlorianH
7 - Meteor

Hi 🙂

 

in order to check IBANs, I want to calculate the modulo 97 of very large numbers. In my example the number is 700901001234567890131400. Two websites independently say, that the result of 700901001234567890131400 modulo 97 is 90 (e.g. https://www.entwicklertools.de/tools/mathematik-tools/modulo-rechner/). But when I calculate it with Alteryx the result is -79. The reason for this miscalculation seems to be, that the Formula-Tool can not handle numbers, that are as large as the first one. Does anyone have an idea how to work around that?

 

FlorianH_1-1625749918427.png

 

Thanks a lot in advance!

4 REPLIES 4
apathetichell
19 - Altair

correction - you asked this question 3 months ago - and @Qiu made you a macro... as I said at the time -mod is an integer function and your number is larger than Int64. it will not work with mod on Alteryx... or excel.. there might be a python/r way.

Qiu
21 - Polaris
21 - Polaris

@apathetichell 
Wow, I did not recall until you brought it up. Thanks a lot.

@FlorianH 
Here is my reply.

I can anwser some queries from you after your review of the flow.

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/MOD-formula-gives-unexpected-result/td...

apathetichell
19 - Altair

FYI here's the R way...

dat <- read.Alteryx("#1", mode="data.frame")
install.packages("VeryLargeIntegers", repos='http //cran.us.r-project.org')
library(VeryLargeIntegers)

VLIMOD <- data.frame(c("value"))
for (i in 1:nrow(dat)) {
x <- as.vli(as.character(dat$VLI[i]))
VLIMOD[i] <- as.numeric(summod(x,0,dat$Divisor[i])$value)}


write.Alteryx(VLIMOD,1)

 

this assumes:

1) you don't have VeryLargeIntegers  already installed and you can install packages in your R Tool

2) you MUST name your columns VLI (for the big number) and Divisor for the number you are dividing by.

3) you'll have to transpose the output because everything is in one row.

FlorianH
7 - Meteor

Hi @Qiu 

 

thanks a lot! Unfortunately I'm not at all familiar with macros in Alteryx. I will try to solve it with python now.

 

Thanks anyway.

 

Cheers

 

Florian

Labels
Top Solution Authors