More > JRiver Media Center 24 for Windows
expression help list of favourites and using populating calculated field
wer:
Try this:
--- Code: ---IfElse(And(IsEqual([Favourites],Jonnie Albums,8),IsEqual([Favourites],Lise Albums,8)),Both,IsEqual([Favourites],Jonnie Albums,8),Jonnie Only,IsEqual([Favourites],Lise Albums,8),Lise Only)
--- End code ---
I still don't know what you mean by "select Lise from the acceptable values above" because an expression cannot "select" anything. It returns values, and it will return whatever value you dictate. If you mean that you want it to actually extract the text from the list item of [Favourites] that can be done, but I think it's needlessly complicated because [Favourites] has restricted and known values. So I think the expression above does what you want.
I don't know where you went wrong with your AND since you gave no examples, but it should be clear from the above that since AND tests values it requires a complete test expression (which will itself evaluate to a value) in each clause. I've seen other people get confused with it though.
I deliberately left the output strings different than your example, to make the code clear. Change the strings "Both", "Jonnie Only", and "Lise Only" to whatever you want it to return in those cases.
wer:
I see you posted again while I was posting. The code I gave you above does what you were originally intending, if I understood enough.
--- Quote from: lise on December 08, 2020, 07:04:06 pm ---Here's the code I need (it comes from the two bolded lines below)
If [Favourites] contains Jonnie Albums, then write Jonnie (total should be 63)
If [Favourites] contains Lise Albums, then write Lise (total should be 105)
--- End quote ---
That is how my expression will count. The count of Jonnie + the count of Lise will be greater than the total favourites, because the unions (Lise&Jonnie) are counted for both.
wer:
So just to expand on this, for anyone else who might be interested in IfElse() or And()... Here's the expression formatted for easier reading:
--- Code: ---IfElse(
And(
IsEqual([Favourites],Jonnie Albums,8),
IsEqual([Favourites],Lise Albums,8)),
Both,
IsEqual([Favourites],Jonnie Albums,8),Jonnie Only,
IsEqual([Favourites],Lise Albums,8),Lise Only)
--- End code ---
The main IfElse contains 3 tests: an AND, and two IsEqual tests.
The AND itself compares two IsEqual tests, and if they are both true, outputs the text "Both".
If the AND test is not true, the IfElse moves on to the next test, IsEqual.
If the first IsEqual is true (the string in [Favourites] contains "Jonnie Albums") then it outputs "Jonnie Only" and otherwise, we go to the next test.
The last test is the same as the previous, but for Lise.
If none of the tests evaluates as true, the IfElse expression returns null (no output at all).
There is more than one way to evaluate for this set of conditions (it could be done with an IfCase statement or a Regex for example) but IfElse is the closest to what the OP originally understood, and is probably the easiest to understand.
lise:
Thanks for the explanation of how the code works. I appreciate it.
--- Quote from: wer on December 08, 2020, 07:18:41 pm ---
--- Code: ---IfElse(And(IsEqual([Favourites],Jonnie Albums,8),IsEqual([Favourites],Lise Albums,8)),Both,IsEqual([Favourites],Jonnie Albums,8),Jonnie Only,IsEqual([Favourites],Lise Albums,8),Lise Only)
I deliberately left the output strings different than your example, to make the code clear. Change the strings "Both", "Jonnie Only", and "Lise Only" to whatever you want it to return in those cases.
--- End code ---
That's the issue. I want the output to be just Lise or Jonnie. I don't want a "both". It is precisely turning that "both" into a "Jonnie" or "Lise" that is giving me headaches.
--- Code: ---I still don't know what you mean by "select Lise from the acceptable values above" because an expression cannot "select" anything. It returns values, and it will return whatever value you dictate.
--- End code ---
I meant "return" one of those two values, either Lise or Jonnie.
Basically, if "Jonnie Album" is checked in [Favourites] - output Jonnie. If "Lise Album" is checked, output Lise.
Nothing else.
But boy, putting that into code...
I don't think it is possible with if/then, or maybe even with else. I spent most of this afternoon trying it with ListContains instead, convinced that a "contains" would work better because it wouldn't matter if both are checked, but no luck so far.
--- End quote ---
lise:
--- Code: ---IfElse(And(IsEqual([Favourites],Jonnie Albums,8),IsEqual([Favourites],Lise Albums,8)),[b]BOTH[/b],IsEqual([Favourites],Jonnie Albums,8),Jonnie Only,IsEqual([Favourites],Lise Albums,8),Lise Only)
--- End code ---
Where you have "Both", is there a way to output to both Jonnie and to Lise instead of "Both"?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version