INTERACT FORUM

Please login or register.

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

Author Topic: [Solved] Grouping expression help (CD Reference ID)  (Read 2499 times)

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
[Solved] Grouping expression help (CD Reference ID)
« on: August 22, 2010, 01:32:30 pm »

Some time ago, Marko helped me create a view that allowed my CD Reference IDs to be grouped in groups of 160, starting from 1 (vs. the built in 0-based list counting).  This required duplicating the search expressions, for as many groupings as I needed, as noted here: http://wiki.jrmediacenter.com/index.php/CD_Reference_Number, but it worked fine for those purposes.

However, I would now like to sub-group those by 10, and as you can see from the grouping in column 2, the groupings are correct for my needs, since they too are 0-based (the first grouping should be 1 - 10).  There are just too many sub-groupings now to attempt to manage creating the individual expressions; furthermore, changing the sub-grouping size to, for example, 40, would require all new expressions.

Is there any other way this can be done?

ps. one of the reasons I'd like to sub-group, is to discover where the holes are in the contiguous list of Ref Ids.  Is there are way to do this quickly?
Logged
The opinions I express represent my own folly.

gappie

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 4565
Re: Grouping expression help
« Reply #1 on: August 22, 2010, 03:20:38 pm »

have you tried something like
RemoveRight([reference id,0],1)0-RemoveRight([reference id,0],1)9

 :)
gab
Logged

wo0zy

  • Recent member
  • *
  • Posts: 14
Re: Grouping expression help
« Reply #2 on: August 22, 2010, 03:35:40 pm »

Yikes! I have sooo much to learn about this product  :o

I always thought searching by album, artist of track was good enough.

Guess it's time to start working on my understanding of the expression language.

Awesome stuff.

Wo0zy
Logged

gappie

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 4565
Re: Grouping expression help
« Reply #3 on: August 22, 2010, 03:57:00 pm »

Yikes! I have sooo much to learn about this product  :o

I always thought searching by album, artist of track was good enough.

Guess it's time to start working on my understanding of the expression language.

Awesome stuff.

Wo0zy
its fun, just dont get intimidated. it are the out of normal problems that get the weirdest answers..  8)


have you tried something like
RemoveRight([reference id,0],1)0-RemoveRight([reference id,0],1)9

 :)
gab
MrC: when you want that to have a grouping like
1_10
11-20
etc

this is the expression that seems to work for me:
Code: [Select]
Math(RemoveRight(Math([reference id,0]-1),1)0+1)-Math(RemoveRight(math([reference id,0]-1),1)9+1)i expect that that could be done much more elegant..  8)
 :)
gab
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Grouping expression help
« Reply #4 on: August 22, 2010, 06:57:39 pm »

Thanks, that does work for grouping by 10.

I don't understand how the range is being created.  If I simply use "1-10" as an expression, I get no results.  But it seems that the expression just basically does this, so there must be something I'm not understanding about my hard-coded value vs. what is returned by the expression?

[edit: I understand now.  The set of selected items from (typically left-most) categories are applied to the expression.  The expression creates a result, which is a set of labels (categories).  This selected result(s) further reduce the set to those that created the selected label.]
Logged
The opinions I express represent my own folly.

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Grouping expression help
« Reply #5 on: August 22, 2010, 10:56:28 pm »

Here is a more general solution for 1-based grouping by X (replace X by the desired grouping size):
Code: [Select]
PadNumber(Math(X*(FormatNumber(Math(([Ref ID]-1)/X+0.5))-1)+1),4)-
PadNumber(Math(X*(FormatNumber(Math(([Ref ID]-1)/X+0.5))-1)+X),4)

For Search lists, a more general solution to that posted on the CD Reference Number page is (whitespace added for clarity)
Code: [Select]
If(IsEmpty([Ref ID],1),
   Unassigned,
      PadNumber(Math(X*(FormatNumber(Math(([Ref ID]-1)/X+0.5))-1)+1),4)-
      PadNumber(Math(X*(FormatNumber(Math(([Ref ID]-1)/X+0.5))-1)+X),4))

I'll update the Wiki page.
Logged
The opinions I express represent my own folly.

gappie

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 4565
Re: Grouping expression help
« Reply #6 on: August 23, 2010, 06:52:13 am »

Very nice...  8)

 :)
gab
Logged

wo0zy

  • Recent member
  • *
  • Posts: 14
Re: Grouping expression help
« Reply #7 on: August 23, 2010, 02:19:37 pm »

Here is a more general solution for 1-based grouping by X (replace X by the desired grouping size
Code: [Select]
PadNumber(Math(X*(FormatNumber(Math(([Ref ID]-1)/X+0.5))-1)+1),4)-
PadNumber(Math(X*(FormatNumber(Math(([Ref ID]-1)/X+0.5))-1)+X),4)

For Search lists, a more general solution to that posted on the CD Reference Number page is (whitespace added for clarity)
Code: [Select]
If(IsEmpty([Ref ID],1),
   Unassigned,
      PadNumber(Math(X*(FormatNumber(Math(([Ref ID]-1)/X+0.5))-1)+1),4)-
      PadNumber(Math(X*(FormatNumber(Math(([Ref ID]-1)/X+0.5))-1)+X),4))

I'll update the Wiki page. ;D

That's amazing. If you have the time to walk an expression noob through how this works I know one that'd be happy to learn :)

If not no worries I'll start working my way through the wiki later in the week.

Wo0zy
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: [Solved] Grouping expression help (CD Reference ID)
« Reply #8 on: August 23, 2010, 02:21:18 pm »

Thanks.  I explained it here.
Logged
The opinions I express represent my own folly.

wo0zy

  • Recent member
  • *
  • Posts: 14
Re: [Solved] Grouping expression help (CD Reference ID)
« Reply #9 on: August 23, 2010, 04:45:14 pm »

Thanks.  I explained it here.

Thanks. Digesting now.

Could take me a while :)

Wo0zy
Logged
Pages: [1]   Go Up