INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Expression expertize required  (Read 572 times)

SkGe

  • Galactic Citizen
  • ****
  • Posts: 433
Expression expertize required
« on: December 20, 2018, 04:18:12 am »

Hello there.
I struggle to create a expression and it seems i'm not able to solve by myself. If someone who have a better knowledge about it, maybe can help me.
The expression is this:
if(ListContains([publication rating], AllMusic-0.5, 0), 10,)if(ListContains([publication rating], AllMusic-1, 0), 20,)if(ListContains([publication rating], AllMusic-1.5, 0), 30,)if(ListContains([publication rating], AllMusic-2, 0), 40,)if(ListContains([publication rating], AllMusic-2.5, 0), 50,)if(ListContains([publication rating], AllMusic-3, 0), 60,) if(ListContains([publication rating], AllMusic-3.5, 0), 70,)if(ListContains([publication rating], AllMusic-4, 0), 80,)if(ListContains([publication rating], AllMusic-4.5, 0), 90,)if(ListContains([publication rating], AllMusic-5, 0), 100,)
So the expression instead show me the value i have in that field, when meet the .5 value it show the same value where is none.
Ex of the custom field:
AllMusic-3 value it shows 60
AllMusic-3.5 value it show 60, instead as 70. The problem i think it is in these .5 and dunno how to avoid this issue.
I did try different variants of expression but none work.
Thanks
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Expression expertize required
« Reply #1 on: December 20, 2018, 05:35:45 am »

i would certainly look at using ifelse() instead of if()

Code: [Select]
ifelse(ListContains([publication rating], AllMusic-0.5, 0), 10,ListContains([publication rating], AllMusic-1, 0), 20,ListContains([publication rating], AllMusic-1.5, 0), 30,ListContains([publication rating], AllMusic-2, 0), 40,ListContains([publication rating], AllMusic-2.5, 0),ListContains([publication rating], AllMusic-3, 0), 60,ListContains([publication rating], AllMusic-3.5, 0), 70,ListContains([publication rating], AllMusic-4, 0), 80,ListContains([publication rating], AllMusic-4.5, 0), 90,ListContains([publication rating], AllMusic-5, 0), 100,)
i didn't test that so watch the brackets etc. but it will be closer
Logged

swiv3d

  • Guest
Re: Expression expertize required
« Reply #2 on: December 21, 2018, 04:52:32 pm »

From your description of what is happening it looks like the decimal place is causing a problem. Try putting an escape character in front of the decimal places eg 1/.5, 2/.5 etc  - it might help. Using ferday's expression is also a lot simpler than the string of if statements.
Logged
Pages: [1]   Go Up