More > JRiver Media Center 24 for Windows

expression help list of favourites and using populating calculated field

<< < (4/6) > >>

wer:
Just replace the word both with whatever you want it to say.

lise:
Yeah, I know I can replace it with any word I want. I guess what I was asking is if I could replace it with two strings instead of one. So instead of "Both", it could be both "Lise" and "Jonnie". But I doubt that is possible, at least it wouldn't be easy.

I appreciate the time you took to help with the code. Unfortunately, it gives unexpected results.  I'll try and figure it out. I don't want to take up more of your time. You've been generous enough as it is.



--- 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 ---

Result:
Expression Column
 All Expressions (4)
 0,Both,0,Jonnie Only,0,Lise Only)
 0,Both,1,Jonnie Only,0,Lise Only)
 1,Both,0,Jonnie Only,1,Lise Only)
 1,Both,1,Jonnie Only,1,Lise Only)

And when I insert the code you explained:


--- 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 Results are:
Expression Colum
 All Expression (4)
 0,...
 0,...
 1,...
 1,...

wer:
The code formatted for easy reading isn't tested for execution. Don't use it. Use the first one.

The first one works, I've tested it.  It's possible you made a cut and paste error, or it's possible your fields aren't setup as described.

Please show me a screenshot of the file list with all the involved fields visible, so I can see what you actually have. 

The code was tested against a database that had a list-type field called Favourites, that contained a combination of Jonnie Albums;Lise Albums

You refer to an expression column in your last post.  Please show me a screenshot of how you got that output, because the code that I gave you cannot generate an output of:

Expression Column
 All Expressions (4)
 0,Both,0,Jonnie Only,0,Lise Only)
 0,Both,1,Jonnie Only,0,Lise Only)
 1,Both,0,Jonnie Only,1,Lise Only)
 1,Both,1,Jonnie Only,1,Lise Only)

wer:

--- Quote from: lise on December 08, 2020, 10:07:57 pm ---I guess what I was asking is if I could replace it with two strings instead of one. So instead of "Both", it could be both "Lise" and "Jonnie". But I doubt that is possible, at least it wouldn't be easy.

--- End quote ---

Maybe the way you are using the terminology is confusing me.

The test case for the IfElse can output one string. Not any other number of strings, just one.  Two strings concatenated together are just one string. That string could be any of the following:
Both
Lise and Jonnie
"Lise and Jonnie"
Lise;Jonnie

You can however force MC to interpret that one string as another data type. This is called data type casting. You can cast a string as a list by appending
--- Code: ---&datatype=[list]
--- End code ---
to the string.  So you could have MC output "Lise;Jonnie" as a string, or you could cast that string as a list:

--- Code: ---IfElse(And(IsEqual([Favourites],Jonnie Albums,8),IsEqual([Favourites],Lise Albums,8)),Lise;Jonnie&datatype=[list],IsEqual([Favourites],Jonnie Albums,8),Jonnie Only,IsEqual([Favourites],Lise Albums,8),Lise Only)

--- End code ---
In which case, MC outputs one list Lise;Jonnie instead of one string. The list has two elements, Lise and Jonnie.
I'm not sure how you would make use of that.

However, none of that explains how you got that erroneous output. Maybe something is missing in what you're telling me.

wer:
Oh... Are you actually using MC24?  The expression language was enhanced in MC26. I wonder if And() is not present in MC24.

Click the magnifying glass in the expression editor dropdown, and look at the insert function menu.  Check and see if your MC has all the functions we are using.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version