INTERACT FORUM

Please login or register.

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

Author Topic: Help for grouping expression  (Read 2626 times)

Otello

  • World Citizen
  • ***
  • Posts: 204
Help for grouping expression
« on: March 18, 2016, 12:58:11 pm »

Hi guys, can somebody please help me modifying my grouping expression for Operas?

Code: [Select]
listbuild(1, / -/ , [Composer],
    listbuild(1, / -/ , [Album],
        listbuild(1, / -/  , [Date] - By [Conductor], [Artist], [Orchestra])),  [Publisher])

I'd like to insert,  between "()", the custom field [Selection] after  [Album], but only if the field is not empty.

For instance:

Wagner - Die Walkure - 1967 - Karajan - etc.
Wagner - Die Walkure (Act 1) - 1935 - Walter - etc.

BTW, while trying myself with poor results, I went close to my goal but the string ended with 3 periods: "..."
Does somebody know the meaning of these 3 periods?  ;D



Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8009
Re: Help for grouping expression
« Reply #1 on: March 18, 2016, 01:33:32 pm »

I don't understand why you're using listbuild.  But maybe this is just an area I haven't messed with very much.

To be clear, are we talking about Standard View using a category that is an Expression?  One expression to group by and an optional expression to display something different?  If so, I don't think listbuild is required at all.

As for your question about how to display:
([Selection])

I would do it like this:

Code: [Select]
if(isempty([Selection]),,/([Selection]/))
Brian.
Logged

Otello

  • World Citizen
  • ***
  • Posts: 204
Re: Help for grouping expression
« Reply #2 on: March 18, 2016, 02:04:39 pm »

I don't understand why you're using listbuild.  But maybe this is just an area I haven't messed with very much.

To be clear, are we talking about Standard View using a category that is an Expression?  One expression to group by and an optional expression to display something different?  If so, I don't think listbuild is required at all.

As for your question about how to display:
([Selection])

I would do it like this:

Code: [Select]
if(isempty([Selection]),,/([Selection]/))
Brian.

I'm not sure why I ended up using Listbuild, but I think I had problem with unwanted "-" in case of empty fields and somebody on the forum suggested this script.
We are talking about the Library Item I use for "Group By:" in Panes view.

Now I'm here:

Code: [Select]
listbuild(1, / -/ , [Composer],
   listbuild(1, / -/ , [Album], if(isempty([Selection]),,/([Selection]/))
      listbuild(1, / -/  , [Date] - By [Conductor], [Artist], [Orchestra])),  [Publisher])

But I get the minus sign at the wong place, before and not after [Selection]:

Wagner - Die Walkure - (Act 1) 1935 - Walter - etc.

I imagine I'd get rid of the first 2 Listbuild, right?


Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8009
Re: Help for grouping expression
« Reply #3 on: March 18, 2016, 02:25:18 pm »

Again, I don't get the lists.  You could try removing the second one, sure.  Or try removing all of them and making it a straight up expression without the listbuild functions.  Or you could move the 2nd list build inside of the if() clause.

Brian.
Logged

Otello

  • World Citizen
  • ***
  • Posts: 204
Re: Help for grouping expression
« Reply #4 on: March 18, 2016, 02:36:54 pm »

Brian, I cannot make a straight up expression because in case of empty fields what I get is aesthetically horrible.  ;)

For instance, with empty Date I'd get:

Wagner - Siegfried - - Karajan etc.
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Help for grouping expression
« Reply #5 on: March 18, 2016, 04:19:35 pm »

You can fix that with the Delimit() function or with If(IsEmpty()) functions.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

Otello

  • World Citizen
  • ***
  • Posts: 204
Re: Help for grouping expression
« Reply #6 on: March 18, 2016, 06:16:25 pm »

For the record, I've found the genesis of my old script:

https://yabb.jriver.com/interact/index.php?topic=69432.msg467753#msg467753

Reading the old thread, I realize that MrC suggested to use Listbuild to make the list working with any field missing.
Actually, in my Opera view, Composer and Album must have a value, so I can make it simpler removing the first 2 Listbuild.

Adding  if(isempty([Selection]),,/([Selection]/)) I get this:

Code: [Select]
[Composer] - [Album] if(isempty([Selection]),,/([Selection]/)) - listbuild(1, / -/  , [Date] - By [Conductor], [Artist], [Orchestra],[Publisher])
It almost work.
I mean, it seams to work, but looking carefully I get an unwanted double space before Publisher:

... Orchestra -  Publisher
(can you see 1 space after Orchestra and 2 spaces before Publisher?)

Of course it's absolutely trivial, but I'm getting mad trying to figure where the extra space comes from!  ;D
Logged
Pages: [1]   Go Up