Expand my Community achievements bar.

Don’t miss the Workfront AMA: System Smarts & Strategic Starts! Ask your questions about keeping Workfront running smoothly, planning enhancements, reporting, or adoption, and get practical insights from Adobe experts.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

SOLVED

Checking if a Number is Exactly Divisible by Specific Values

Avatar

Level 9

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:

entryDatehours
01-02-202332
03-05-202322.5
31-01-202332.4
26-02-202316
12-04-202316.2
01-06-202314

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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_0-1686411386901.png

If you like my content, please take a moment to view and vote on my Idea Requests: https://tinyurl.com/4rbpr7hf

View solution in original post

7 Replies

Avatar

Community Advisor

 

 
There is no native MOD function, but IF(ROUND(hours/8) = hours/8),”8 Exactly”,”Not 8”) etc. is a possible workaround.
 
Regards,
Doug

Thanks Doug!! 🙂

Avatar

Correct answer by
Community Advisor

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_0-1686411386901.png

If you like my content, please take a moment to view and vote on my Idea Requests: https://tinyurl.com/4rbpr7hf

Avatar

Level 9

@William-- Thank you for the detailed explanation 🙂

Avatar

Community Advisor

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.

Avatar

Level 9

Thank you, Chris. However, when I tested the expression "{{100 % 8}}", it returned a remainder of 4.

Avatar

Community Advisor

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)