Problem with $if statement

[#31]
T=7
F=%featartist%$regexp(%TITLE%,'^(.+?)\s+[[({<]?\s*(?:featuring|feat\.?|ft\.?)\s*([^])}>]+)\>\s*[])}>]?(.*)$','$2$3+++$1',1)
1=%featartist%+++%title%

[#32]
T=5
F=ARTIST
1=$if(%FEATARTIST%,%artist%' feat. '%FEATARTIST%,)

[#33]
T=5
F=SUBTITLE
1=$if($eql(%itunesadvisory%,1),Explicit,%subtitle%)

[#34]
T=5
F=SUBTITLE
1=$if($eql(%itunesadvisory%,2),Clean,%subtitle%)

[#35]
T=5
F=MIXNAME
1=%artist%

[#36]
T=7
F=%mixname%
1=%dummy% [%mixname%]

[#37]
T=7
F=%artist%
1=%artist% [%dummy%]

[#38]
T=5
F=SUBTITLE
1=$if(%mixname%,%mixname% - %subtitle%,%subtitle%)

[#39]
T=5
F=TITLE
1=$if(%subtitle%,%title% '['%subtitle%']',%title%)

What I'm trying to achieve is to format SUBTITLE... if MIXNAME is filled - then if SUBTITLE is filled - prepend MIXNAME to SUBTITLE - otherwise just use SUBTITLE if it is filled.

I have tried using multiple $if statements, but can't get it to work.

Below, are the following outcomes I want from SUBTITLE before appending it to TITLE.

SUBTITLE: Clean
+
MIXNAME: Extended
=
SUBTITLE: Extended - Clean

SUBTITLE:
+
MIXNAME: Extended
=
SUBTITLE: Extended

SUBTITLE: Clean
+
MIXNAME:
=
SUBTITLE: Clean

And then...

TITLE: Hello
+
SUBTITLE: Clean
=
TITLE: Hello [Clean]

TITLE: Hello
+
SUBTITLE:
=
TITLE: Hello

You could try an action of the type "Format value" for SUBTITLE
Format string: [%mixartist% ]%subtitle%
The [] work like an IF statement.

F=%featartist%$regexp(%TITLE%,'^(.+?)\s+[[({<]?\s*(?:featuring|feat\.?|ft\.?)\s*([^])}>]+)\>\s*[])}>]?(.*)$','$2$3+++$1',1)
1=%featartist%+++%title%

[#32]
T=5
F=ARTIST
1=$if(%FEATARTIST%,%artist%' feat. '%FEATARTIST%,%artist%)

[#33]
T=5
F=SUBTITLE
1=$if($eql(%itunesadvisory%,1),Explicit,%subtitle%)

[#34]
T=5
F=SUBTITLE
1=$if($eql(%itunesadvisory%,2),Clean,%subtitle%)

[#35]
T=5
F=MIXNAME
1=%artist%

[#36]
T=7
F=%mixname%
1=%dummy% [%mixname%]

[#37]
T=7
F=%artist%
1=%artist% [%dummy%]

[#38]
T=5
F=SUBTITLE
1=%subtitle%[%mixname%]

[#39]
T=5
F=TITLE
1=if(%title%,%title% '['%subtitle%']',)

That seems ok now, for some reason though the entire artist field is still appearing in MIXNAME, instead of being blank if there is no string enclosed in [].

I don't know how you create the field MIXNAME or how you want to get rid of the artist if it does not belong there.