INTERACT FORUM

Please login or register.

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

Author Topic: Help with the IfElse() function  (Read 4459 times)

DangerJP

  • World Citizen
  • ***
  • Posts: 121
Help with the IfElse() function
« on: August 29, 2014, 09:42:16 am »

Hi,

I’m trying to use an IfElse() –based expression in a category view.

I want to be create a category based on the [Genre] field.

For example, let’s say that the album Bitches Brew by Miles Davis has the following [Genre] values in my library:

Jazz Fusion; Avant-Garde Jazz

In my category view, I would like to use the following expression:
IfElse(IsEqual([Genre], Avant-Garde Jazz, 8), AVJ, IsEqual([Genre], Jazz Fusion, 8), JF)

When using this expression, the album Bitches Brew only appears under the “AVJ” category, which is the first true statement calculated by the IfElse(…).

Actually, I would like Bitches Brew to appear in both AVJ and JF categories; both statements are true under IfElse(…).

Is there another way to accomplish this task ?

Thanks !
Logged

Arindelle

  • Citizen of the Universe
  • *****
  • Posts: 2772
Re: Help with the IfElse() function
« Reply #1 on: August 29, 2014, 10:28:22 am »

very interested in this .... I've been trying to do something sort of similar. Now I have Grouping=>Genre=>Style


eg. ArtistX - Grouping: Country and Pop/Rock  Genres: Alt. Country, Indie Pop&Folk, Folk-Rock

what I want is sort of a Taxonomy where Categories for Country would contain Alt; Country but not Indie Pop&Folk or Folk-Rock; Pop/Rock would contain  Indie Pop&Folk and Folk-Rock,but not  Alt. Country. Maybe not totally the same as you but..

Anyways I dropped this from my priorities, but Mr.C was telling me I had to combine lists with multiple criterion per list ListCombine(…) -- if I understood correctly (probably didn't because I couldn't figure it out).  

Maybe someone will pitch in on this  ?
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Help with the IfElse() function
« Reply #2 on: August 29, 2014, 10:46:25 am »

i've tried...without success so far.  listcombine will combine two lists, but the ifelse functions will still only take one item at a time from the string.  i have been unsuccessful in trying to figure a way to OR/AND these functions, it appears the capability is not built in

my workarounds are to create multiple custom fields, so one ifelse function will evaluate to one field, then the next ifelse will evaluate to another field, etc. then i can group everything that way.  it's clunky but it does work.  for example i've sorted everything into average bitrates (if lossy) using a smartlist, entered that output into a custom field, then used another custom field to sort those average bitrates into readable output (like CD rip, high res, fix please, etc.)

the better way involves regex() which i haven't tackled yet, but it can search a whole string for certain values (so it's kind of an OR/AND function, at least from how i read the wiki)

 



Logged

Arindelle

  • Citizen of the Universe
  • *****
  • Posts: 2772
Re: Help with the IfElse() function
« Reply #3 on: August 29, 2014, 10:50:51 am »

regex  :'( i dont wanna learn regex  :'(

HELP MR.C!!
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Help with the IfElse() function
« Reply #4 on: August 29, 2014, 10:58:45 am »

i really want to learn regex, i think it will change my MC world

but i don't have time!  i'd always figured, as soon as i find time, i'll figure it out....then make a wiki entry for it that shows my steps LOL since the only way i'll learn it is one step at a time.  i'm a trial and error programmer ha ha
Logged

DangerJP

  • World Citizen
  • ***
  • Posts: 121
Re: Help with the IfElse() function
« Reply #5 on: August 29, 2014, 12:28:18 pm »

Thanks for the replies !

Arindelle, I think we want to accomplish something similar.

For genre, my albums are tagged with the following fields:
[Genre] : specific genres, as retrieved from rateyourmusic.com. I have around 350 different genres in my library (crazy, I know...). Ex. : Jazz Fusion, IDM, Thrash Metal, etc.
[Main Genre]: Umbrella genres, as retrieved from rateYourmusic.com. I have around 15 main genres in my library. Ex. : Pop, Rock, Electronic, Jazz, Classical Music, etc.

Then there's everything in between. Let's take Ride The Lightning by Metallica.
[Genre] = Thrash Metal
[Main Genre] = Rock
But the whole "genre tree" would be : Rock - Metal - Thrash Metal.

This is a simple example with 3 genre levels. It can get more complicated with really specific genres like Dubstep (5-6 genre levels within the Electronic main genre), albums with multiple main genres, bla bla. I don't want to tag all my albums with 5-6 different genre fields (2 is enough!), but I would like to create some sort of database to represent the relations between genres.

Ultimately, I think I would like to create a sort of "genre tree" view where you can drill into specific genres/styles from Main genres of music.
Like getting a glimpse of the history and evolution of music through the genres relations.

I'm feeling like the ultimate geek now...
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Help with the IfElse() function
« Reply #6 on: August 29, 2014, 12:55:49 pm »

Thanks for the replies !

Arindelle, I think we want to accomplish something similar.

For genre, my albums are tagged with the following fields:
[Genre] : specific genres, as retrieved from rateyourmusic.com. I have around 350 different genres in my library (crazy, I know...). Ex. : Jazz Fusion, IDM, Thrash Metal, etc.
[Main Genre]: Umbrella genres, as retrieved from rateYourmusic.com. I have around 15 main genres in my library. Ex. : Pop, Rock, Electronic, Jazz, Classical Music, etc.

Then there's everything in between. Let's take Ride The Lightning by Metallica.
[Genre] = Thrash Metal
[Main Genre] = Rock
But the whole "genre tree" would be : Rock - Metal - Thrash Metal.

This is a simple example with 3 genre levels. It can get more complicated with really specific genres like Dubstep (5-6 genre levels within the Electronic main genre), albums with multiple main genres, bla bla. I don't want to tag all my albums with 5-6 different genre fields (2 is enough!), but I would like to create some sort of database to represent the relations between genres.

Ultimately, I think I would like to create a sort of "genre tree" view where you can drill into specific genres/styles from Main genres of music.
Like getting a glimpse of the history and evolution of music through the genres relations.

I'm feeling like the ultimate geek now...

i've created a "genre tree" view reasonably successfully by using keywords

i've kept my [genre] small, kind of like your [main genre]
i've then assigned keywords to the albums, so under [genre] = metal, metallica gets "thrash", while say something like opeth may get "progressive";"folk";"gothic"


it's pretty easy to "tree" all successive keywords as desired...keywords is an easy list to work with for both views and smarlists, and it's easy to use pane tagging with keywords, even when you have hundreds of them.  the nice thing, is that a broad sub-genre like "folk" will extend across rock, metal, pop, electronic, etc. and i can tree the views by choosing say [electronic], keywords dubstep,chillstep, etc.

you could also use your 2 [genre] categories, and then use keywords to tree it even better, so [electronic] [bass music] "dubstep" or "chillstep" or "progstep" etc.

i tried at first to use something more like your method, with [genre] and [subgenre] but i'm really happy with my current method. 
Logged

DangerJP

  • World Citizen
  • ***
  • Posts: 121
Re: Help with the IfElse() function
« Reply #7 on: August 29, 2014, 12:57:28 pm »

Ferday,

Interesting ! I will certainly explore this avenue...


Thanks !
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Help with the IfElse() function
« Reply #8 on: August 29, 2014, 01:07:36 pm »

the only hard part is assigning all the keywords LOL.  i've gotten about 40% of my 200,000 audio tracks done so far

since you mentioned metal:

i have a view that has panes at the top with [genre],main keyword,second keyword,third keyword,4th keyword...

so i could tree [metal],death,experimental,industrial and get a pretty specific sub-sub-sub genre to listen to.  or if i chose [all genres],industrial,experimental, i would get a list that may contain metal, and some electronic stuff as well.

i'm really into music history, so i could add [year] (i've made a custom [Era] tag) and pick [metal],black,[Era] and do a history of black metal playlist....
Logged

6233638

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 5353
Re: Help with the IfElse() function
« Reply #9 on: August 29, 2014, 01:32:54 pm »

 
Sorry, but it's not clear to me in the first post DangerJP - are you just trying to rename your genres with this expression?
 


Nested genres are normally designated with a backslash.

To use ferday's example, you would tag tracks as:
 
Electronic\Bass Music\Chillstep
Electronic\Bass Music\Dubstep
Electronic\Bass Music\Progstep
Electronic\Other\Ambient
 
Then simply using a Genre view would present:

Code: [Select]
Electronic Bass Music Chillstep
Dubstep
Progstep

Other Ambient

You could also use custom fields to designate sub-genres instead, I suppose.
That could make editing the tags easier if you're using multiple genres and sub-genres for all your music.
Logged

fridden

  • Recent member
  • *
  • Posts: 31
Re: Help with the IfElse() function
« Reply #10 on: August 29, 2014, 01:35:57 pm »

I might have misunderstood everything, and given that you have a lot of genres my suggestion might not be practical, but why don't you just use nested Replaces? As I understand it you want to order all Avant-Garde Jazz under the category AGJ, and all the Jazz Fusion under the category JF ?

I set up a new category view.
The first category is an expression like this:
Code: [Select]
Replace(Replace([Genre,0],Avant-Garde Jazz,AGJ),Jazz Fusion,JF)&datatype=[list]
    Like I said, if you have a lot of genres the expression gets very long. You also need to beware of replacing genres with similar wordings in correct order.

    For instance, if I want to have MJF for Modern Jazz Fusion, I would have to put that before the replacement of Jazz Fusion, and so on.

    Hope this helps.
    /fridden
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5177
  • "Linux Merit Badge" Recipient
Re: Help with the IfElse() function
« Reply #11 on: August 29, 2014, 01:58:51 pm »

Nested genres are normally designated with a backslash.

This completely blew my mind, I had no idea this functionality existed and I've been creating custom fields for sub-genres all this time.  Amazing  ;D
Logged

6233638

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 5353
Re: Help with the IfElse() function
« Reply #12 on: August 29, 2014, 02:15:27 pm »

This completely blew my mind, I had no idea this functionality existed and I've been creating custom fields for sub-genres all this time.  Amazing  ;D
;D
 
There are advantages and disadvantages to both methods.
It's certainly easier to have multiple sub-genres applied to a track when you use a separate [sub-genre] field.
 
Keeping it all in a single genre field makes things simpler for me since I don't really use genres much beyond very broad-reaching categories like "Electronic", "Rock", "Classical" etc. or else I'm hunting through lists of genres\sub-genres to try and find an album or artist.
The most complex things get in my library are: "Soundtrack\Film Soundtrack; Electronic" since I seem to get a lot of film/game soundtracks bundled with other purchases, and I like them to also show up in the relevant category for their specific style of music.
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Help with the IfElse() function
« Reply #13 on: August 29, 2014, 02:20:10 pm »

;D
 
There are advantages and disadvantages to both methods.
It's certainly easier to have multiple sub-genres applied to a track when you use a separate [sub-genre] field.
 
Keeping it all in a single genre field makes things simpler for me since I don't really use genres much beyond very broad-reaching categories like "Electronic", "Rock", "Classical" etc. or else I'm hunting through lists of genres\sub-genres to try and find an album or artist.
The most complex things get in my library are: "Soundtrack\Film Soundtrack; Electronic" since I seem to get a lot of film/game soundtracks bundled with other purchases, and I like them to also show up in the relevant category for their specific style of music.

mine are very complex, hence i use keywords (rather than another custom field, but same thing) since the keywords can reach over any genre, while nested genres are stuck as nests

i nest genres all the time with my documents however, where it makes sense with my workflow

as you said, there's benefits to both (and other) methods of doing it.

in case you're still reading this 6233638, do you know if regex() may in fact be the right expression to pull from strings (such as the OP may have been asking) in place of ifelse?
Logged

6233638

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 5353
Re: Help with the IfElse() function
« Reply #14 on: August 29, 2014, 02:58:31 pm »

in case you're still reading this 6233638, do you know if regex() may in fact be the right expression to pull from strings (such as the OP may have been asking) in place of ifelse?
It's not even clear to me what DangerJP is trying to do.
It looked like he was just trying to rename "Avant-Garde Jazz" to "AVJ" and "Jazz Fusion" to "JF"
Logged

DangerJP

  • World Citizen
  • ***
  • Posts: 121
Re: Help with the IfElse() function
« Reply #15 on: August 31, 2014, 07:52:13 am »

Thanks all for your replies !

I realised I was not clear in my first post.

I'm not trying to ''batch rename'' fields, as supposed by 6233638.

I'm trying to define categories with an IfElse() expression.


Example:
I have this single album Feel by Ty Segall. Using the RateYourMusic website genre structure, I tag this album with the following genres:
Neo-Psychedelia
Indie Rock

Starting from the first level (Main Genre) in the genre structure, the whole ''genre lineage'' for this album would be:
Rock -> Psychedelic Rock; Alternative Rock -> Neo-Psychedelia; Indie Rock.
It's a simple 3 level case.

In my library, I use the standard field [Genre] to assign last level genres to my albums. I also use a custom [Main Genre] field to assign first level genres to my albums.
So, in this case, these fields would have the following values:
[Main Genre] = Rock
[Genre] = Neo-Psychedelia; Indie Rock

I don't use any other fields for intermediate level genres (it's already crazy enough...).
So, I would like to create a view to drill through the genre levels, using the IfElse() function or any other method.

In an attempt to create such a view, I would use the following expression to retrieve the second level genre from the [Genre] field:
IfElse(IsEqual([Genre], Neo-Psychedelia, 8, Psychedelic Rock, IsEqual([Genre], Indie Rock, 8, Alternative Rock)

For that Ty Segall album, both statements in the IfElse() function are true, but only the first one is catched by MC.

So, this album only appears under Psychedelic Rock, while it should also appear under Alternative Rock (as shown in the attached picture).


So it's probably an IfElse() limitation...

I will try the solutions proposed in this thread and report back.

Thanks again !

Logged

6233638

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 5353
Re: Help with the IfElse() function
« Reply #16 on: August 31, 2014, 09:25:02 am »

I don't understand why, but I think I see what you're trying to do now:
You're tagging files with a top-level genre, and a "bottom-level" genre, but want to calculate the second-level genre from the existing tags rather than tagging the files.
 
Well your IfElse() statement "won't work" because you're saying:
"If the Genre is Neo-Psychedelia, then set second-level genre to Psychedelic Rock. Otherwise do this _____"
Since the genre is Neo-Psychedelia, the second-level genre is set to "Psychedelic Rock" and there is nothing more to be done. The IfElse() statement is working correctly.
 
I don't really see a way to do this without an expression which is excessively long and totally unmanageable once you want to make changes, since you no doubt have a lot of genres.
It seems like it would be far easier to create a third field and tag your files instead.
Logged

Arindelle

  • Citizen of the Universe
  • *****
  • Posts: 2772
Re: Help with the IfElse() function
« Reply #17 on: August 31, 2014, 10:37:45 am »


It seems like it would be far easier to create a third field and tag your files instead.
+1

yes actually what you are trying do is pretty easy IF i understand (actually your expression might work by allowing the view to filter in both directions but it would be a PITA.. Not even sure why you would have to re-tag at all -- or why use an expression see screen shots.  You could make calculated data fields, which will automatically port over from the existing fields. There are 4 of these fields in the SSs below ("genres" are auto-populated by genre or vice-versa) this is very handy for Artist when you have two or more main performing artists and is not a various artist compilation.

The problem I have with this is that having/combining multiple top level entries per artist or per album. If you have for example county-folk under both pop/rock and country it gets messy drilling down.
Logged
Pages: [1]   Go Up