INTERACT FORUM

Please login or register.

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

Author Topic: Help with an Expression please  (Read 723 times)

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Help with an Expression please
« on: January 17, 2020, 07:50:31 pm »

I have created a new field called C.Year (Composed Year) for use with Classical albums that are a composite of pieces written in different years (e.g. Strauss Waltzes). It is an Integer, one value per Album.

In the normal Year Field I have the date of composition for each track, which means for a single Symphony et al there is only one year per album.

However, where there are more than one year for tracks on an album it shows as "1874.8 avg", and I want to convert that to 1874 for the field C.Year.
Unfortunately using the expression left([Year], 4) just gives me [Varies] instead of 1874 because it is still looking at each track Year rather than however that  displayed 1874.8 avg is calculated for an album. Is there a hidden formula for that calculation? If not, how can I achieve the result?

CHeers
FF
Logged

SkGe

  • Galactic Citizen
  • ****
  • Posts: 433
Re: Help with an Expression please
« Reply #1 on: January 17, 2020, 08:26:24 pm »

You can try
formatnumber([your field]) and this it should round the number on your field.
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #2 on: January 17, 2020, 11:32:06 pm »

Thanks, but no go. That is still trying to work on the same level as left([Year], 4) (i.e. track level not album level)

Edit: I noticed that even though I set one value per album it gets changed to one value per value (and then gets greyed out so can't be changed). I assume that this is because Year is a per file field and if I use that in the expression then that is also then converted to a per file field.

I think that means I need to know how to calculate "1874.8 avg" which is the sum of the track Years divided by the number of tracks, but how to express that??
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Help with an Expression please
« Reply #3 on: January 19, 2020, 02:50:02 am »

you can get the number of tracks per album with

ItemCount(AlbumKey/(/))

as for summing and dividing, the only way to do that is with global variables.  it's a fun space to play in but also not intuitive.  if you make a new smartlist and past this into the "import/export"

Code: [Select]
[=save(0,var_number_of_tracks[album artist (auto)][album])1]=1 [=save(0,var_album_year_sum[album artist (auto)][album])1]=1 [=save(math(1+load(var_number_of_tracks[album artist (auto)][album])),var_number_of_tracks[album artist (auto)][album])1]=1 [=save(math([Year]+load(var_album_year_sum[album artist (auto)][album])),var_album_year_sum[album artist (auto)][album])1]=1 [=save(math(load(var_album_year_sum[album artist (auto)][album]) / load(var_number_of_tracks[album artist (auto)][album])),var_album_year[album artist (auto)][album])1]=1 [Media Type]=[Audio] ~sort=[Album DR Average],[Filename],[Artist],[Media Type],[Album Artist (auto)],[Album],[Disc #],[Track #]
then, add an expression column to the smartlist and paste this:

Code: [Select]
formatnumber(load(var_album_year[album artist (auto)][album]),0)
the result should be what you are looking for.....
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #4 on: January 19, 2020, 03:28:14 am »

Thanks ferday. I'll give that some oxygen tomorrow (Sunday evening here in Oz)
Logged
Pages: [1]   Go Up