Author Topic: Native $Count function not always working [NOT A BUG - EXPLAINED]  (Read 900 times)

Bee-liever

  • Member
  • Hero Member
  • *****
  • Posts: 3871
  • MB Version: 3.6.9255 P
The native $Count(<field>,<grouping-field>) doesn't appear to be working consistently.

Code
$Count(<Composer>,<Album>)
will only return "0" as result but
Code
$Count(<Sort Composer>,<Album>)
returns correct results.

Similarly
Code
$Count(<Conductor>,<Album>)
will only return "0".
Last Edit: January 25, 2024, 11:37:49 PM by Bee-liever
MusicBee and my library - Making bee-utiful music together

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 34978
The native $Count(<field>,<grouping-field>) doesn't appear to be working consistently.
Code
$Count(<Composer>,<Album>)
will only return "0" as result but
Its working for me but perhaps a debatable point is its using the display composer, not the split out composers. Is that what the issue is?

Bee-liever

  • Member
  • Hero Member
  • *****
  • Posts: 3871
  • MB Version: 3.6.9255 P
$Count(<Composer>,<Album>) only returns "0" for me.


but I noticed something unusual with $Count(<Sort Composer>,<Album>)

The values in the RH red square match the number of composers in the LH red square.

If you take notice of the value in the blue square you can see that it also returned "0"
The values for the working album (Toccata) are custom values I have entered for sort as: in the sorting tab.

Could this be because I'm still on 3.5 and not yet using 3.6?
MusicBee and my library - Making bee-utiful music together

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 34978
is the preview function is the reason you are reporting this? functions in unsaved virtual tags arent supported and will show inconsistently depending on what you did before. The virtual tag should work when saved and displayed in a panel
Last Edit: January 25, 2024, 08:33:57 AM by Steven

Bee-liever

  • Member
  • Hero Member
  • *****
  • Posts: 3871
  • MB Version: 3.6.9255 P
is the preview function is the reason you are reporting this?
Yes it is.
That bit of information would have been helpful back here:
https://getmusicbee.com/forum/index.php?topic=35587.msg194606#msg194606  :-\

And it would explain why $Count functions won't work in complex virtual tags by themselves

$If($Or($Contains(<Path>,Classical)="T",$Contains(<Genre>,Classical Crossover)="T"),
$If($Or($Contains(<Keywords>,ACC)="T",$Count(<Conductor>,<Album>)>1),
$IsNull(<Set Subtitle>,
$IsNull(<Conductor>,"• "<Sort Composer>" •","• "<Sort Composer>" "{font: Sinzano;Regular;8.25}" CON."{font: Sinzano;Regular;11}$RSplit(<Conductor>," ",1)" •"),
$IsNull(<Conductor>,"• "<Sort Composer>" ¦ "<Set Subtitle>" •","• "<Sort Composer>" "{font: Sinzano;Regular;8.25}" CON."{font: Sinzano;Regular;11}$RSplit(<Conductor>," ",1)" ¦ "<Set Subtitle>" •")),
$IsNull(<Set Subtitle>,,$If($Contains(<Set Subtitle>,Bonus Track)=T,,"• "<Set Subtitle>" •"))),
$If(<Disc Count>>1,
$IsNull(<Set Subtitle>,"• Disc "<Disc#>" •","• "<Set Subtitle>" •  "{font: Sinzano;Regular;9.5}{contrast: 50}"Disc "<Disc#>{contrast: default}{font: Sinzano;Regular;11}),
$If(<Track#>>1,$IsNull(<Set Subtitle>,,"• "<Set Subtitle>" •"),)))

The $Count function has to be defined in it's own virtual tag:
CondNo.  =  $Count(<Conductor>,<Album>)

that then can be plugged into the other virtual tag
$If($Or($Contains(<Path>,Classical)="T",$Contains(<Genre>,Classical Crossover)="T"),
$If($Or($Contains(<Keywords>,ACC)="T",<CondNo.>>1),
$IsNull(<Set Subtitle>,
$IsNull(<Conductor>,"• "<Sort Composer>" •","• "<Sort Composer>" "{font: Sinzano;Regular;8.25}" CON."{font: Sinzano;Regular;11}$RSplit(<Conductor>," ",1)" •"),
$IsNull(<Conductor>,"• "<Sort Composer>" ¦ "<Set Subtitle>" •","• "<Sort Composer>" "{font: Sinzano;Regular;8.25}" CON."{font: Sinzano;Regular;11}$RSplit(<Conductor>," ",1)" ¦ "<Set Subtitle>" •")),
$IsNull(<Set Subtitle>,,$If($Contains(<Set Subtitle>,Bonus Track)=T,,"• "<Set Subtitle>" •"))),
$If(<Disc Count>>1,
$IsNull(<Set Subtitle>,"• Disc "<Disc#>" •","• "<Set Subtitle>" •  "{font: Sinzano;Regular;9.5}{contrast: 50}"Disc "<Disc#>{contrast: default}{font: Sinzano;Regular;11}),
$If(<Track#>>1,$IsNull(<Set Subtitle>,,"• "<Set Subtitle>" •"),)))

that allows it to work correctly.

Some of those extra virtual tags in 3.6 I'm already earmarking  ;)
MusicBee and my library - Making bee-utiful music together

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 34978
There is a bug when referencing aggregate functions in $Or, $And
This should fix that:
https://getmusicbee.com/patches/MusicBee36_Patched.zip

This doesnt change what i said about usage with the preview function
Last Edit: January 26, 2024, 03:36:57 AM by Steven

Bee-liever

  • Member
  • Hero Member
  • *****
  • Posts: 3871
  • MB Version: 3.6.9255 P
Okay, Okay...
I've bit the bullet and moved to 3.6  ::)

Thank you for the patch fixing the $Or, $And bug.
MusicBee and my library - Making bee-utiful music together