INTERACT FORUM

Please login or register.

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

Author Topic: An easy one for you syntax gurus ...  (Read 890 times)

apostos

  • World Citizen
  • ***
  • Posts: 146
An easy one for you syntax gurus ...
« on: January 02, 2013, 11:53:39 am »

What I’m trying to accomplish – a custom field called “resolution” for display in the Movie views (small & large). This field will use an expression (unfortunately, yet to be determined).

Basically – If [Width] = 1920  and [Height] = 1080 is true, then display 1080p - or else - if [Width] = 1280  and [Height] = 720 is true then display 720p.

I’ve created the new field (apparently that’s the easy part), but so far I’ve been struggling with the expression language. Multiple attempts in and I’m still creating expression gobbledygook with no sign of progress …

Any help much appreciated.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: An easy one for you syntax gurus ...
« Reply #1 on: January 02, 2013, 01:04:09 pm »

Using the existing [Dimensions] field:

IfElse(
   IsEqual([Dimensions], 1920 x 1080), 1080p,
   IsEqual([Dimensions], 1280 x 720), 720p,
   1, Other
)

You can remove the Other line if you don't want anything output for non 1080p / 720p cases.
Logged
The opinions I express represent my own folly.

apostos

  • World Citizen
  • ***
  • Posts: 146
Re: An easy one for you syntax gurus ...
« Reply #2 on: January 02, 2013, 03:58:10 pm »

Boy, was I on the wrong track.

Thanks for that.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: An easy one for you syntax gurus ...
« Reply #3 on: January 02, 2013, 05:03:15 pm »

I think you had it nailed, and could do it with the two fields [Width] and [Height].  Consider how it would look:

IfElse(
   IsEqual([Width] [Height], 1920 1080), 1080p,
   IsEqual([Width] [Height], 1280 720), 720p,
   1, Other
)

This implicitly does the AND you suggested, by concatenating the values together and doing a single comparison.  Its a nice little trick to avoid the Boolean logic shortcomings in the expression language.  The IfElse() provides the OR.
Logged
The opinions I express represent my own folly.
Pages: [1]   Go Up