More > JRiver Media Center 32 for Mac

Expression for cases

(1/4) > >>

Vadomar:
Hello dear community,

unfortunately I am a coding beginner and need your help. I can't get it to work myself. I am trying to display the artists of a classical music album in a calculated field. I have:

[soloist] = Anne-Sophie Mutter
[conductor] = Herbert von Karajan
[orchestra] = Berlin Philharmonic Orchestra

I am now looking for a formula that shows me the above information in a separate field [artistcalculated]. It should have the following format:

[artistcalculated] = [soloist], [conductor]: [orchestra]

I can get it to work with this special example, but what if there is no soloist? What if there are soloist and orchestra but no conductor (which can happen especially in old chamber music)? How can I make sure the punctuation is right?
Do I have to use the ifelse-function for this or is there another way?

Thank you very much in advance!

zybex:
There's likely a simpler solution, but here's an ugly one that just checks for all 8 combinations:


--- Code: ---ifelse(isempty([soloist][conductor][orchestra]),,
isempty([soloist][_conductor]),[orchestra],
isempty([soloist][_orchestra]),[conductor],
isempty([conductor][orchestra]),[soloist],
isempty([soloist]),[conductor]: [orchestra],
isempty([conductor]),[soloist]: [orchestra],
isempty([orchestra]),[soloist]/, [conductor],
1, [soloist]/, [conductor]: [orchestra])
--- End code ---

lepa:
zybex beats me to it but here is couple of solutions anyway

It depends what you want end result to be

Assuming here that there is always orchestra

e.g. if you want always have same kind of structure where you know which parts exist and which not:

--- Code: ---FirstNotEmpty([soloist],NA), FirstNotEmpty([conductor],NA): [orchestra]
--- End code ---
So it would return e.g.
NA, NA: Berlin Philharmonic Orchestra
Anne-Sophie Mutter, NA: Berlin Philharmonic Orchestra
NA, Herbert von Karajan: Berlin Philharmonic Orchestra
Anne-Sophie Mutter, Herbert von Karajan: Berlin Philharmonic Orchestra

Or you could just return if there is a value (untested expression, might not work but to get you an idea at least):

--- Code: ---If(!IsEmpty([soloist]),[soloist]If(!IsEmpty([conductor]),/,/ [conductor],): [orchestra],If(!IsEmpty([conductor]),[conductor]: [orchestra],[orchestra]))
--- End code ---
e.g.
Berlin Philharmonic Orchestra
Anne-Sophie Mutter: Berlin Philharmonic Orchestra
Herbert von Karajan: Berlin Philharmonic Orchestra
Anne-Sophie Mutter, Herbert von Karajan: Berlin Philharmonic Orchestra

zybex:
Here's a nicer one:

--- Code: ---listbuild(1,/:/ ,listbuild(1,/,/ ,[soloist], [conductor]), [orchestra])
--- End code ---

Lepa's first one with the NA makes sense.

lepa:

--- Quote from: zybex on February 19, 2024, 05:16:30 am ---Here's a nicer one:

--- Code: ---listbuild(1,/:/ ,listbuild(1,/,/ ,[soloist], [conductor]), [orchestra])
--- End code ---

--- End quote ---
indeed  8)

Navigation

[0] Message Index

[#] Next page

Go to full version