More > JRiver Media Center 27 for Windows
How to modify GroupSummaryQuery(Album,Rating,1) to use only 3,4,5 star tracks
FenceFurniture:
The function GroupSummaryQuery(Album,Rating,1) works well enough, but I want to restrict it to only look at 3,4,5 star tracks. The reason for this is that 0,1, or 2 star tracks can be excluded from playing (or even deleted from the library).
For example, say an album has three ***** tracks, one **** track and two rubbish * tracks. GroupSummaryQuery(Album,Rating,1) would give a result of 21 stars divided by 6 tracks = 3.5. However, if those * star tracks are ignored the true rating of the good music is 5+5+5+4 / 4 = 4.75 (or 95% which is my preference for expressing it).
Also, I would like it to display nothing (rather than "? stars") if there are no rated tracks in the abum.
Can someone indicate what I need to modify please?
FenceFurniture:
So using this:
if(compare(Math(GroupSummaryQuery(Album,Rating,1) * 20), >=, 60), Math(GroupSummaryQuery(Album,Rating,1) * 20)%,)
displays it the way I want (like 72% or 86%), but of course does not eliminate the <*** tracks. So the question is: how to ignore <*** tracks?
zybex:
Tricky one! I managed to do it with FieldQuery() but had to work around some issues and possible bugs in this function.
- FieldQuery() seems to return a list consisting of only unique values, so it you have multiple tracks with same rating, it only returns one of them (ie, on your example above it returns 5;4;1 instead of 5;5;5;4;1;1)
- To work around that issue, I added an aux field to force distinct values by using FileKey(), but then FieldQuery() now returns ratings for ALL fileKeys between the first and last file in the album, even if they don't exist, and even if they belong to a different album :/
- if [Album] is empty, FieldQuery seems to match all files
So, this is a somewhat working solution, but may give wrong values for some albums until FieldQuery is fixed:
1. create a Calculated Field called "Rating:Key" with this expression:
--- Code: ---replace([Rating],? stars,0):FileKey()
--- End code ---
2. this then gives you the rating% of an Album:
--- Code: ---save(Regex(fieldquery(Album,[Album],Rating:Key,2,1),/#([345]):#/,-2),_stars)/
if([_stars],FormatNumber(Math(ListMath([_stars],3)*20),1)%,[unrated])
--- End code ---
The expression gets all 'Rating:Key' values for files sharing the same Album, then uses Regex to get only the ratings>=3 and remove the FileKey part. Then uses ListMath to get the average, and Math/FormatNumber to convert to a percentage.
FenceFurniture:
Fantastic, thank you zybex!
I took out the [unrated] so it just displays a blank, but how do I just make it 67% without the decimal place (i.e not 66.7%). (I tried something, but....nup!)
zybex:
Just set the number of decimal places in FormatNumber() to zero:
save(Regex(fieldquery(Album,[Album],Rating:Key,2,1),/#([345]):#/,-2),_stars)/
if([_stars],FormatNumber(Math(ListMath([_stars],3)*20),0)%,[unrated])
Navigation
[0] Message Index
[#] Next page
Go to full version