INTERACT FORUM
More => Old Versions => Media Center 13 (Development Ended) => Topic started by: Qythyx on May 21, 2009, 04:35:47 am
-
I have a complex expression field set in my library that I'm trying to sort on. I have a playlist that is specifically set to sort of this field and I also often add this playlist to Playing Now, and in both cases sorting is not working 100% correctly.
My expression is:
Math((100 + If(IsEqual(Field(Last Played,0),), 100, Math(Now() - Field(Last Played,0)))) / 100 / (10 + If(IsEqual([Number Plays],),0,[Number Plays])) * (If(IsEqual(Field(Rating, 0), ), 6, Field(Rating, 0)) * 15))
This expression equates (for my library) to numbers between just above 0 to around 5. The sorting kind of works, but not entirely. For example, I'll see number like 5.4xxxx sorted out of sequence with 5.3xxxx. In general sorting is correct, in that I don't see 4.xxx mixed in with the 5.xxx, but at the hight precisions they're mixed.
So, am I doing something wrong or is this a bug? Would it help if I made my numbers larger, e.g., multiplied the result by 1000, or something like that?
-
Can anyone else repro this problem? It's actually a bit worse than I said, that is, the numbers are mixed up more than I thought.
Is there anything special that should be done when sorting on an expression field that equates to a number?
-
I tried multipyling my result by 1,000,000 to make the comparisons of intergers instead of high precision decimals and that seemed to work. So, this looks like a bug.
BTW, I didn't mention that this is on 169. Haven't tried 170 yet.
-
End the expression with &DataType=[Number] to let Media Center know it should use numeric sorting. You may need to delete and readd the column, due to a minor bug when changing only the data type.
Otherwise, it uses string sorting (which does have intelligent handling of integers, but not decimals).
Updated expression:
FormatNumber(Math((100 + If(IsEqual(Field(Last Played,0),), 100, Math(Now() - Field(Last Played,0)))) / 100 / (10 + If(IsEqual([Number Plays],),0,[Number Plays])) * (If(IsEqual(Field(Rating, 0), ), 6, Field(Rating, 0)) * 15)), 2)&DataType=[Number]
-
Ahh, that explains it. Thanks.
-
I'm having a similar problem with a calculated field. I deleted the field, rebuilt it with the &DataType=[Number] included and it's still not sorting correctly. It's doing all the internal mathematics correctly, and sorts properly if I manually click the field in the view, but if I refresh the smartlist, it reverts to the close-but-not-quite-right version of the sort.
Has anyone found a solution to this issue?