# Setting a Score based off a range of numbers

**URL:** <https://community.thunkable.com/t/setting-a-score-based-off-a-range-of-numbers/1617307>\
**Category:** Questions about Thunkable X\
**Tags:** beginner, help\
**Created:** [November 15, 2021, 10:31pm UTC](https://community.thunkable.com/t/setting-a-score-based-off-a-range-of-numbers/1617307 "2021-11-15T22:31:16Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielstebbins](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@danielstebbins](https://community.thunkable.com/u/danielstebbins)\
**Post date:** [November 15, 2021, 10:31pm UTC](https://community.thunkable.com/t/setting-a-score-based-off-a-range-of-numbers/1617307/1 "2021-11-15T22:31:17Z")

</div>

I’m working on a project where I need to assign a score to a range of possible numbers. I’m not entirely sure where to start. I attached a screenshot of what I’ve been fiddling around with. Am I on the right track? Using the table below as an example, ideally I’d like to be able to assign any temperature input from 0-6 degrees as a 5, and any distance input from 1.1 to 1.2 miles as a 3. From there I’d like to add two scores (In this case 5 and 3) to reach a final score. Is there anyone who could help me out? Thanks 🙂

 ![Screen Shot 2021-11-15 at 5.29.21 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/4/f4c0fe1ec07f662ffc62b578955d73b29fc04a3b.jpeg)  
 ![IMG-4212](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/c/9cb64fe20a6593d0a0e680eb077315af05207b11.jpeg)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [November 15, 2021, 10:51pm UTC](https://community.thunkable.com/t/setting-a-score-based-off-a-range-of-numbers/1617307/2 "2021-11-15T22:51:10Z")

</div>

It’s certainly possible to do this with a series of if \> and ≤ statements as you demonstrated but it’s a pain and well, there’s a reason we have math! 😉

I usually think about this by starting with the extreme values of each range. So if we divide by the difference in rows (each row is 7 apart from the one above it):

0/7=0  
6/7=0.85  
7/7=1  
13/7=1.85  
…

Then we can round the answers down using a “floor” function and get this:  
floor(0/7)=0  
floor(6/7)=0  
floor(7/7)=1  
floor(13/7)=1  
…

Why is this useful? Well, if we start with the value 5 which is your highest score, we can subtract 0.5 for each row:

Score = 5 - (0.5 \* floor(Temperature / 7)

I think that will work! Now it’s just a matter of finding the right blocks to make that equation.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [November 15, 2021, 11:07pm UTC](https://community.thunkable.com/t/setting-a-score-based-off-a-range-of-numbers/1617307/3 "2021-11-15T23:07:17Z")

</div>

See the “@danielstebbins math” screen in this project:

[https://x.thunkable.com/copy/0676d9efb5142638c347fd2a7dc36245](https://x.thunkable.com/copy/0676d9efb5142638c347fd2a7dc36245)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/d/3d32e0a79912b612f01cbab79cb24466c6026c40.png)

Note that the equation won’t work for values above 62 so you’ll need to check for those and adjust.

---

<div class="post-metadata">

**Author:** ![danielstebbins](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@danielstebbins](https://community.thunkable.com/u/danielstebbins)\
**Post date:** [November 16, 2021, 1:00am UTC](https://community.thunkable.com/t/setting-a-score-based-off-a-range-of-numbers/1617307/4 "2021-11-16T01:00:37Z")

</div>

Thank you so much for your help! The screenshot you posted really helped me to understand some of the blocks a lot better. I’ve been messing around with the idea you gave me and I’m having trouble getting my final score with the layout I designed before. What I’m struggling with is getting the inputs for temperature and distance to convert to the score and then add together in the final score box. Thanks again for your help! 🙂

 ![Screen Shot 2021-11-15 at 7.51.37 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/9/093d2e9ac6a13661c095239c5d86c391a7654b7a.jpeg)  
 ![Screen Shot 2021-11-15 at 7.58.30 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/e/de8aa0e627a3ab0ffd93fdec3933ca47a05d2f07.jpeg)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [November 16, 2021, 1:19am UTC](https://community.thunkable.com/t/setting-a-score-based-off-a-range-of-numbers/1617307/5 "2021-11-16T01:19:47Z")

</div>

The Distance formula you’re using has a divisor of 5 but the difference between each row is 0.2 so you need to divide by 0.2 not 5.

The way I’m calculating that is by looking at the last number in each row:

0.2  
0.4  
0.6  
0.8  
1  
…  
(A difference of 0.2)

For Temperature, it’s a difference of 7:  
6  
13  
20  
27  
34  
…

Which is why I divided by 7 in the formula I created for you.

---

<div class="post-metadata">

**Author:** ![danielstebbins](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@danielstebbins](https://community.thunkable.com/u/danielstebbins)\
**Post date:** [November 18, 2021, 6:49pm UTC](https://community.thunkable.com/t/setting-a-score-based-off-a-range-of-numbers/1617307/6 "2021-11-18T18:49:40Z")

</div>

I changed the number I was dividing by from 5 to 0.2 and no matter what inputs I put in to temperature or distance I only get 10 or 5. I’m wondering how to get the scores to correspond to my table, and then take add the two scores for a final score out of 10. Thanks 🙂

 ![Screen Shot 2021-11-18 at 1.50.22 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/9/19c158a6e6369f8aecd3c287aaf4b5ad4cb0c54f.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [November 18, 2021, 7:08pm UTC](https://community.thunkable.com/t/setting-a-score-based-off-a-range-of-numbers/1617307/7 "2021-11-18T19:08:16Z")

</div>

You’re using the same equations I provided in my demo. So the only thing I can think of is that you are not updating the values when the Temperature or Distance changes. But I can’t see the rest of your project. Can you share a link with me?

**Edit:** It looks like those are all of the blocks you’re using. So you’re setting Temperature and Distance to zero when the screen opens and then the Scores get calculated immediately. So 5 minus 0 equals 5. That’s why you get 5 every time.

How are you going to allow the user to change the values of those variables? I assume you’ll want to use the `textinput's text` blocks from the Text Input drawer in place of the Temperature and Distance variables.

---

<div class="post-metadata">

**Author:** ![mimostel](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mimostel/32/107661_2.png) [@mimostel](https://community.thunkable.com/u/mimostel)\
**Post date:** [November 18, 2021, 7:16pm UTC](https://community.thunkable.com/t/setting-a-score-based-off-a-range-of-numbers/1617307/8 "2021-11-18T19:16:01Z")

</div>

Maybe i didn’t understand right your requirement, as I see a lot of math here, and I’m thinking a straight solution as a CASE IF:

 ![SCREEN](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/3/73befe42a16ef6e3402856b31f8360315167c740.png)

You do same for distance and you get scores easy… 🤔

PS.: If you are not familiar with CASE statement, in that block, app will execute first condition met and then will go further. For example, if TEMPERATURE is 58, will check if 58 \>=63 - NOT, then if 58\>=56 - YES so temperatureSCORE will be 1 then go to the next block.

---

<div class="post-metadata">

**Author:** ![danielstebbins](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@danielstebbins](https://community.thunkable.com/u/danielstebbins)\
**Post date:** [November 18, 2021, 7:30pm UTC](https://community.thunkable.com/t/setting-a-score-based-off-a-range-of-numbers/1617307/9 "2021-11-18T19:30:00Z")

</div>

Yes, I would like the user to change with values with the text inputs I shared a link to my project below 🙂  
[https://x.thunkable.com/copy/d5339e6d8854a3c71b643b6ec9ed5fd5](https://x.thunkable.com/copy/d5339e6d8854a3c71b643b6ec9ed5fd5)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [November 18, 2021, 7:35pm UTC](https://community.thunkable.com/t/setting-a-score-based-off-a-range-of-numbers/1617307/10 "2021-11-18T19:35:03Z")

</div>

Like this:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/3/23dcfa867028a5df679380b4093483f08812da60.png)

Note that for Score 2, you should not add or subtract anything to the product. So I left it as 0 + … instead of 5 + …

---

<div class="post-metadata">

**Author:** ![danielstebbins](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@danielstebbins](https://community.thunkable.com/u/danielstebbins)\
**Post date:** [November 18, 2021, 8:14pm UTC](https://community.thunkable.com/t/setting-a-score-based-off-a-range-of-numbers/1617307/11 "2021-11-18T20:14:51Z")

</div>

Awesome! That’s just what I needed 🙂 Is there any way to make it so any score above 63 for temperature and any score above 2 miles for distance would result in a score of 5? Thanks again!

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [November 18, 2021, 8:36pm UTC](https://community.thunkable.com/t/setting-a-score-based-off-a-range-of-numbers/1617307/12 "2021-11-18T20:36:21Z")

</div>

Sure, just use an If/Else block and set up the logic and math blocks to check for that.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [February 16, 2022, 8:36pm UTC](https://community.thunkable.com/t/setting-a-score-based-off-a-range-of-numbers/1617307/13 "2022-02-16T20:36:51Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
