INTERACT FORUM

Please login or register.

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

Author Topic: View based on multiple OR conditions  (Read 521 times)

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4226
View based on multiple OR conditions
« on: May 10, 2020, 04:19:39 pm »

This should be simple but I don't know how to get the expression language to evaluate to what I want

I want a view which shows results which match either of the following conditions

- Last Played = "never played"
- item is flagged to be rewatched

The former is a built in field
The latter is a custom field which I've added with type = Integer and edit type = Check (i.e. closest approximation of a boolean I could find)

"never played" appears to be a custom rendering of a value of [] . This reads as if it's an empty list but it doesn't seem like any other functions respect this (e.g. isempty, ismissing, listcount)

so basically I want to display where rewatch or not "last played" (assuming a value of 1 evaluates to true and no value evaluates to false)

I have at least 2 problems here

1) what is the default value of a custom field of type integer? it displays as you'd expect as a checkbox but when shown as a plain field, it shows as unset or empty but doesn't respond to ismissing or isempty (or =0)
2) what is the actual value behind "never played"?


Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: View based on multiple OR conditions
« Reply #1 on: May 10, 2020, 05:02:32 pm »

Doesn't something like this work?
Or(IsEqual([Last played],never played),Compare([Rewatch],=,1),Never played or flagged,Watched)
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: View based on multiple OR conditions
« Reply #2 on: May 10, 2020, 07:46:17 pm »

1) what is the default value of a custom field of type integer? it displays as you'd expect as a checkbox but when shown as a plain field, it shows as unset or empty but doesn't respond to ismissing or isempty (or =0)

When such a field is first created it is empty. You can view the raw contents of the field by writing the field as [Rewatch,0].

When you Check the field it is set to 1. When you then uncheck the field it is set to 0. I use such checkbox fields for TV program management, and just test for the field being equal to 1. Depending on the application, it has been recommended to set the field to 0 on import, using Tag on Import, but I haven't found that necessary.



2) what is the actual value behind "never played"?

It is empty. You can view the raw contents of the field by writing the field as [Last Played,0]. When you edit this tag, the only option is to delete an existing value. The Edit Type is "Cealr Only". So IsEmpty(...) will operate on it correctly, using the form IsEmpty([Last Played,0]), and will produce a 0 or 1 result.

So, Lepa's expression could be written differently using the above information;

Or(Compare([Last played,0],=,0),Compare([Rewatch],=,1),Never played or flagged,Watched)



But Lepa's expression doesn't output "Never played or flagged" or "Watched", just 0 or 1.

I went looking for the description in the Expression functions [HELP WANTED] thread and couldn't find it, even though I know it used to be in there. The Release Notes say:
NEW: Added the expression function Or(...) to test a list of values and output true if any are set.

EDIT: Found it, but no more information there. https://yabb.jriver.com/interact/index.php/topic,125140.msg866670.html#msg866670

So I guess the Or(...) function does just output 0 or 1, so the expression needs an If(...) function:

If(Or(Compare([Last played,0],=,0),Compare([Rewatch],=,1)),Never played or flagged,Watched)

Which works to display "Never played or flagged" or "Watched".



Or if you want to use it in a View or Smartlist definition, in "Set Rules for Display"

[=If(Or(Compare([Last played,0],=,0),Compare([Rewatch],=,1)))]=1

But there are probably simpler expressions that could be used. I just wanted to play with the Or(...) function.  :D

Oh yeah, don't need that If(...) any more;
[=Or(Compare([Last played,0],=,0),Compare([Rewatch],=,1))]=1
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4226
Re: View based on multiple OR conditions
« Reply #3 on: May 11, 2020, 10:44:11 am »

Thanks, v helpful

I've never got on with excel style query languages, not sure I ever will :) An embedded script engine using some common language that could query the library would be an interesting option.
Logged
Pages: [1]   Go Up