Sum of two numbers on thunkable returning "NaN"

Hi everyone! I am having issues with this block on thunkable X. Could somebody help me please?

I have two numbers saved on variables called “app variable qtd antiga” and “app variable botão+ naked” and I need to sum both of them, but it returns “NaN”.

Does someone know why?

Thank you so much!

1 Like

One of them isn’t a number. Try displaying each separately in a label?


Thank you for answering me!

Yes, it returns that the app variable “qtd antiga” is not a number, but I initialize this variable to number 1 and I set this variable to a number from the list “app variable Lista Contador”. I dont know why is this not a number

Without knowing what all the variables are (there are several I don’t see defined in the screenshot), it’s hard to identify the problem. Two thoughts:

  1. add a 1s wait block between existing blocks. Occasionally, I’ve seen it where the setting action in the previous block isn’t done before the next block starts, which might explain it. Easy to try, anyway.

  2. Do more debugging. You know you’re getting to the end with a NaN value. Add a “set label’s text” at a bunch of intermediate steps. Hopefully you’ll easily spot where things go wrong.


I would add another suggestion as “a good guideline” although may not be the cause of the issue here.

  • Avoid using “+” in the variable name as it could result in unexpected results in some situations.
1 Like

Most likely, you need to convert those two values to numbers by adding zero to each before you try to get the sum. If that still doesn’t work, then you need to check the value of each variable using a label first.

Thank you for answering it! I added the zero before I tried to get the sum. The problem is that when I get the first occurence of an item from a list “Lista Produtos”, it returns a number. But then, when I set a variable called “qtd antiga” to get the item from this position from a list, that is a number, it returns “NaN”. It doesn’t make any sense…

Oi taiskleinoliveira8y3
Pelo seu código imagino que fale português né?
Você conhece alguma comunidade brasileira de thunkable?
Aqui é bom, mas é raro encontrar “BR”.
Eu ouvi dizer que o thunkable classico vai acabar, ou que o google não vai mais dar suporte aos apps criados com ele, por causa da API 29.
É verdade isso?
Será que vale a pena migrar pro thunkable x?

Oii! Sim, falo português! Nao conheço comunidade de brasileiros, mas seria bem bom encontrar haha. Olha, não sei mesmo… eu comecei direto no thunkable X, nunca usei o clássico, porque queria criar direto pra IOS junto com android. Mas acredito que dê pra perguntar no chat do thunkable pros profissionais do thunkable mesmo!

You have to convert both variables to numbers, not just one. So it should be [0 + app variable qtd antiga] + [0 + app varialbe botao+ naked]


Thanks! But is still not working…

I put everything with “0+”, but the “app variable qtd antiga” is still “NaN”. The “app variable botao+naked” is a number and I can do other calculation with it.

However, when I change the block below
For this:

Than, it returns a number. Then, I think the problem is in “app variable teste final”, but I dont know what is wrong.

Then you have to debug the app variable teste final. Figure out where you’re setting it’s value. Either post a screenshot of those blocks or a link to your project.

Hi there,

I can see that you’re setting qtd angia to:

in list [app variable Lista Contador] get # (in list [app variable Lista Produtos] find first occurrence of item [j]) + 0

I would like to ask about the variable j here. This block is usually used when you are iterating through a list, but I can see that there is no for each item j in list block here. I also don’t see a block where the value of j is set in this screenshot.

What value do you expect j to have in these blocks?

1 Like