Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to use divide "/" function and between (50 to 100) in an if/else statement

Avatar

Avatar
Give Back
Level 2
alik98709228
Level 2

Likes

3 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Ignite 1
Validate 1
Boost 3
Boost 1
View profile

Avatar
Give Back
Level 2
alik98709228
Level 2

Likes

3 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Ignite 1
Validate 1
Boost 3
Boost 1
View profile
alik98709228
Level 2

13-03-2021

Hello,

 

In my list, there are two columns, Men and Women. Men value is '10', Women value is '5'.

I wan to convert following formula to use in an if else statement:

 

if (Men - Women) / Men == '50' to '100' then show this...

I am using following but its not working:

 

<% if (Number(targetData.Men) - Number(targetData.Women)) / Number(targetData.Men) =='50' to'100" )  { show this}

else { show this} %>

 

Any idea how to edit this statement to make it work?

 

Thanks!

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
MVP
Darren_Bowers
MVP

Likes

78 likes

Total Posts

263 posts

Correct Reply

85 solutions
Top badges earned
Validate 1
Affirm 50
Establish
Give Back 3
Applaud 25
View profile

Avatar
Validate 1
MVP
Darren_Bowers
MVP

Likes

78 likes

Total Posts

263 posts

Correct Reply

85 solutions
Top badges earned
Validate 1
Affirm 50
Establish
Give Back 3
Applaud 25
View profile
Darren_Bowers
MVP

14-03-2021

Hi @alik98709228 - you can try something like this:

<% if ( ((Number(targetData.Men) - Number(targetData.Women)) / Number(targetData.Men)) >= 50 && ((Number(targetData.Men) - Number(targetData.Women)) / Number(targetData.Men)) <= 100 )  {...} else {...} %>

 Cheers

Darren

Answers (1)

Answers (1)

Avatar

Avatar
Give Back
Level 2
alik98709228
Level 2

Likes

3 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Ignite 1
Validate 1
Boost 3
Boost 1
View profile

Avatar
Give Back
Level 2
alik98709228
Level 2

Likes

3 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Ignite 1
Validate 1
Boost 3
Boost 1
View profile
alik98709228
Level 2

14-03-2021

Hi Darren,

 

I tried but I am keep getting syntax error:

 

<% if ( ((Number(targetData.Men) - Number(targetData.Women)) / Number(targetData.Men)) >= 50 && ((Number(targetData.Men) - Number(targetData.Women)) / Number(targetData.Men)) <= 100 ) {...} else {...} %>

 

Do you think 50 and 100 should be within quotation marks like '50' and '100'?

And there should be "else if" not just "else"?

 

Let me know.

 

Thanks!