INTERACT FORUM

Please login or register.

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

Author Topic: Custom 'Decade' field needed for movies  (Read 5095 times)

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Custom 'Decade' field needed for movies
« on: February 04, 2017, 02:39:33 pm »

To all you 'expression coders' out there --:: I would like to group my movies by decades, so need to create a new lib field 'Decade', that is to calculate/sum up a value for all movies made within a decade (e.g. between 1990-1999) and output this e.g. as '1990s' into the field.
I have tried sth like this formula (derived from another one to help me get started):
"formatYear(math([year,4]/1),10)" -- where '4' is the number of digits to process, '1' the smallest value (as it was in the other formula, assuming it might work here too), and '10' the number of years to calc/add up into the output value...

Can anyone help me with the correct way to do this? A big THANK YOU in advance!!
Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Custom 'Decade' field needed for movies
« Reply #1 on: February 04, 2017, 03:03:06 pm »

formatrange([date (year)],10)

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Custom 'Decade' field needed for movies
« Reply #2 on: February 04, 2017, 03:24:09 pm »

formatrange([date (year)],10)
Excellent, thank you so much!

And can I modify the output, e.g. to say "1990s", is that possible too?
Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Custom 'Decade' field needed for movies
« Reply #3 on: February 04, 2017, 03:47:17 pm »

Marko's solution taught me something.  I didn't know that function existed.  However, I don't think it's exactly what the OP wants.  I think he wants something more like this:

Code: [Select]
math(trunc([Year]/10,0) *10)s
Give that a try and see if it suits you needs.

Brian.
Logged

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Custom 'Decade' field needed for movies
« Reply #4 on: February 04, 2017, 04:49:59 pm »

Thank you, I've tried and replaced Marko's code with yours, but the only output value is '0s', for all years...

Or did you mean to append that code to the first, e.g.

Code: [Select]
formatrange([date (year)],10) math(trunc([Year]/10,0) *10)s

??

>> Ed.: Tried to append but that's not working... still would be nice to 'truncate' the value, any other suggestions?
Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Custom 'Decade' field needed for movies
« Reply #5 on: February 04, 2017, 05:00:02 pm »

I'm not sure why you would get 0s for that expression.  I cut and pasted that expression directly from here into an expression column and it worked correctly.

Try displaying your [Year] field right next to it.  Does the Year field show 4 digit years?

Brian.
Logged

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Custom 'Decade' field needed for movies
« Reply #6 on: February 04, 2017, 05:13:01 pm »

Yes, all years are 4 digits (as they should ;-)!

Maybe we're using different methods? I've created the new 'Decade' field under "Options > Library & Folders > Manage Library Fields > Add New Field", entering the expression under "Calculated Data".
I've tried both Marko's and your codes individually and combined, but only Marko's does what I want (output is e.g. '1990-1999' for all movies of that decade).
So what I still need is a shorter form, e.g. '1990s'... but I guess that's not so simple ;-)
Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Custom 'Decade' field needed for movies
« Reply #7 on: February 04, 2017, 05:27:47 pm »

I've tried this as an expression column for testing. That's my normal method.

Just now I added a library field, with calculated data, and pasted in the expression.  Displaying this new field shows the values as expected (1990s, 1960s, 2000s, etc).

Post a screen shot of your field definition and/or the display you see in a View.  I'm unsure why this wouldn't be working.

Brian.
Logged

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Custom 'Decade' field needed for movies
« Reply #8 on: February 04, 2017, 06:01:36 pm »

OK, so here it is, the Options window (on top, right) showing the editor, the tag action window (beneath, left) showing the field output:
Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Custom 'Decade' field needed for movies
« Reply #9 on: February 04, 2017, 06:11:54 pm »

And the same using your expression:

Am I doing sth wrong?
Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Custom 'Decade' field needed for movies
« Reply #10 on: February 04, 2017, 07:54:30 pm »

BTW, don't wonder about some German terms in the screenshots, that's my language ;-)

Is anybody going to find a clue to that expression? I suppose the two formulas could be combined in some way, perhaps sth like this?:

Code: [Select]
formatrange(math[trunc(year)]/10,0) *10)s
(not working, just guessing ;-)
Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Custom 'Decade' field needed for movies
« Reply #11 on: February 04, 2017, 10:56:20 pm »

Try replacing [year] with [date (year)]
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Custom 'Decade' field needed for movies
« Reply #12 on: February 05, 2017, 07:25:08 am »

I also wonder if there's something going on with the language.  Because the Year field isn't being show as Year, but rather as it's German translation, I don't know how MC works in this circumstance.  Does JRiver even see a Year field then?

As Ferday suggested, the [date (year)] notation is definitely worth trying.

Brian.
Logged

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Custom 'Decade' field needed for movies
« Reply #13 on: February 05, 2017, 08:19:37 am »

Try replacing [year] with [date (year)]

Do you mean like this?:

Code: [Select]
math(trunc([date (year)]/10,0) *10)s
What magic, this one works! Maybe the others didn't because localized versions of MC need the full specification of the field '[Date (Year)] to interpret an expression correctly...

Thank you all for helping!
Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Custom 'Decade' field needed for movies
« Reply #14 on: February 05, 2017, 08:34:33 am »

I also wonder (...) Does JRiver even see a Year field then?

Yes of course it has a year field, only the English label is replaced by the German one... ;-)

The screenshot below shows the output for both fields in Tag Editor (left) using the new expression for 'Decade' (germ. 'Jahrzehnt'):
Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Custom 'Decade' field needed for movies
« Reply #15 on: February 05, 2017, 08:43:10 am »

The new field even works fine when selecting multiple files of one decade, as you can see below:

Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Custom 'Decade' field needed for movies
« Reply #16 on: February 05, 2017, 07:10:46 pm »

glad it's working.  FWIW i have no luck ever with the [year] field, but [date (year)] always works.  i always figured it was some format (the way they are stored maybe) but never cared as it's easy enough to work around

Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Custom 'Decade' field needed for movies
« Reply #17 on: February 05, 2017, 11:39:36 pm »

Teamwork. Nice one. Thanks Brian, thanks ferday :)

andrewberg, glad to see you're all set now.
Pages: [1]   Go Up