Hello community,
I'm working with Fusion and I'm trying to find a way to determine if a number (input bundle) is exactly divisible by specific values using math functions available. Specifically, I want to check if decimal values (representing hours) are divisible by numbers like 8.1, 8 or 7.5 (see table below)
Is there a built-in function or a combination of functions that can help me achieve this? I'll be using routers, so as a starting point the logic for divisibility by 8 would suffice. Thank you in advance for your support!
Bundles:
entryDate | hours |
01-02-2023 | 32 |
03-05-2023 | 22.5 |
31-01-2023 | 32.4 |
26-02-2023 | 16 |
12-04-2023 | 16.2 |
01-06-2023 | 14 |
Solved! Go to Solution.
Views
Replies
Total Likes
Would be nice if Fusion had a function to check if a value is an integer or not, but since it doesn't (to my knowledge), the below can be used. (this matches the logic provided by Doug)
Since you're using a router, I've put this logic in a filter to determine if the bundle should pass the filter or not:
This uses an IF statement that only allows TRUE responses to pass through:
"if X / Y = a whole number, then X / Y will also = the rounded value of X / Y" E.g.:
10 / 8 = 1.25
The rounded value of 10 / 8 = 1
1.25 does not equal 1, therefore the comparison returns "false."
24/ 8 = 3
The rounded value of 24 / 8 = 3
3 does equal 3, therefore the comparison returns "true."
Thanks Doug!!
Views
Replies
Total Likes
Would be nice if Fusion had a function to check if a value is an integer or not, but since it doesn't (to my knowledge), the below can be used. (this matches the logic provided by Doug)
Since you're using a router, I've put this logic in a filter to determine if the bundle should pass the filter or not:
This uses an IF statement that only allows TRUE responses to pass through:
"if X / Y = a whole number, then X / Y will also = the rounded value of X / Y" E.g.:
10 / 8 = 1.25
The rounded value of 10 / 8 = 1
1.25 does not equal 1, therefore the comparison returns "false."
24/ 8 = 3
The rounded value of 24 / 8 = 3
3 does equal 3, therefore the comparison returns "true."
@William-- Thank you for the detailed explanation
Views
Replies
Total Likes
Fusion has a MOD function in it, which can indicate divisibility. The format is {{numerator & denominator}}, or for example, this: {{100 % 2}}. It will return 0 for divisibility = true, or 1 for divisibility = false.
Edit: This is sort of right, see my follow up comment below.
Thank you, Chris. However, when I tested the expression "{{100 % 8}}", it returned a remainder of 4.
Views
Replies
Total Likes
Oof no yeah, you're right. No late-night posting for me.
The mod command is the modulus command, so it shows the remainder. So for 100 mod 8, 96 (12 * 8 ] is the greatest whole number you can end up with, with a remainder of 4 (100 - 96). So if the result is 0, then that means there was no remainder left, and so the numerator is wholly divisible. (Note: ] is only because if I use normal paren it converts to emoji)
Views
Likes
Replies