INTERACT FORUM

Please login or register.

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

Author Topic: [Varies] and empty values  (Read 307 times)

Buldarged

  • Recent member
  • *
  • Posts: 36
[Varies] and empty values
« on: November 19, 2023, 08:22:45 am »

Hi, I'm searching for a method to figure out if all selected files in a group have the same value for a given tag. I have a tag [Completed], which I set to either "✕" or "✔", depending on, if the file has all the tags I want it to have and if the quality of the file is sufficient. E.g a mp3 album, that has a flac version available gets an "✕". A 1080p movie that was re-released in 4K also gets an "✕". This tag is for the most files in my library currently empty.

Some of my views are categories views and I want to promote the [Completed] tag up in the hierarchy. So if I categorize by [Year], the thumbnail text at that level should be [Year] [Completed] (e.g. "2012 ✕" or "2015 ✔"). Of course that would result in a lot of "[Varies]", which I don't want. I want the [Completed] tag to not show up if it is "[Varies]".

I made a simple expression
Code: [Select]
[Year] If(isequal([Completed],[Varies],1),,[Completed]) to do exactly that. And it works how it should, but the "[Varies]" value does not work how I thought it would. [Varies] seems to not take empty tags into account. E.g. if of two files, one is "✔" and the other is empty, the result is not [Varies], but "✔". But I also can't test for emptiness, since at the point where the expression is executed, the tags are already summarized at that point.

I've come up with two possible solutions. One is to use custom rules in the view with save and load expressions to summarize the [Completed] tag on my own. However, my past experiences have shown, that this approach is very slow and does not scale.

The second possible solution would be to use a dedicated empty value. This could work with the existing expression, but I think its difficult enforcing that this value is set for all files.

Maybe there are better solutions like using grouping functions or something else I've not thought about. Hope you can help me.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8009
Re: [Varies] and empty values
« Reply #1 on: November 19, 2023, 08:32:33 am »

It might be a good idea to outline the result you want to achieve, rather than the technical details.  I can't really figure out what result you are after.  EG:  What is your workflow in choosing your files.  Or what should a particular view show you in various circumstances.

My two thoughts (without understanding exactly your purpose) are:

1.  A Panes view is much more straightforward to navigate.  It's easier to select multiple values, isolate particular values, and make selections based on combinations of fields.
2.  I think you've combined two different pieces of data into a single field.  If you separate those things out, it might be easier for you to use the fields for selecting files.  I particular you should probably have these two fields:

* Tag complete :  you have the tag values you want
* Picked version:  This is the most superior version or the highest resolution version.

In general, trying to operate on aggregated values of your variables is very hard in MC.  Global Variables were created for this purpose.  They are quite confusing for me and I avoid using them.

Best of luck to you,
Brian.
Logged

Buldarged

  • Recent member
  • *
  • Posts: 36
Re: [Varies] and empty values
« Reply #2 on: November 19, 2023, 10:02:09 am »

The result I want to achieve is that if all files in a group have the [Completed] tag set to ✔, then a ✔ should appear in the text of that group.

I used panes views before and while they are certainly versatile, I just can't stand their visual aesthetics. I went from having panes views with a large number files, to having many dedicated views that show only a subset of files. This gives me option the customize each view to the data is displayed. That includes if and how the files are grouped, sorted and displayed.

You are also right that I could split the [Completed] tag up. That would provide additional insight in what is or isn't wrong with a certain file. I've however decided that an additional tag I have to set manually is even more work, especially since I'm only interested if something is wrong rather than what is wrong. It's not really related to the issue I'm trying to solve now.

What I'd really need would be a GroupCountIf(condition) function, that only counts up if the condition for a certain file evaluates to true. Than I could write something simple like
Code: [Select]
IsEqual(GroupCount(), GroupCountIf(IsEqual([Completed],"✔",0)),2) to figure out if all files in a group have the completed tag set.

But since that doesn't exists, I think I'll try out the approach using the global variables. Like I said, I previously used views with a large number of files in which global variables were too slow. But for the smaller views it might be actually work out just fine.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2397
Re: [Varies] and empty values
« Reply #3 on: November 19, 2023, 11:26:02 am »

This can be done with FieldQuery(), but that's too slow if you have a large collection.

The easy solution is to create a new field that automatically replaces the blank values with something:
- create a new calculated field called [_isCompleted] with expression firstNotEmpty([Completed],✕)
- use it on your thumbnail text: [Year] If(isequal([_isCompleted],[Varies],1),✕,[_isCompleted])
Logged

Buldarged

  • Recent member
  • *
  • Posts: 36
Re: [Varies] and empty values
« Reply #4 on: November 19, 2023, 01:37:08 pm »

I like those two solutions.
I tried the FieldQuery() for now and since it can operate on the files in the current view only and my views do not have that many files, it does not cause a perceptible delay.
The thumbnail text now looks like the following:
Code: [Select]
[Year] if(IsEqual(GroupCount(), ListCount(FieldQuery(Completed,✔,Name,1,0))),✔,)
Works perfectly so far, but maybe I'll try out your second solution as well, since it seems to be even faster.
Thank you for these great solutions :)
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8009
Re: [Varies] and empty values
« Reply #5 on: November 20, 2023, 09:14:34 am »

Wow, FieldQuery() is surprising!  I didn't know you could access multiple values (same field across many files) with anything other than global variables.  This isn't nearly as good as having a SQL query available, but it's pretty neat.

I think I need to just stop answering database related questions here.  Zybex gives better answers than I do every time!  Nice job.  :)

Brian.
Logged
Pages: [1]   Go Up