Cascading if statement


I am trying to use the following if statements to format the Album tag based on if either the temporary ReleaseEdition and ReleaseType tags or both are filled. However I can not get the statement covering both tags to process.

1=$if(%releaseedition%,%album% '{'%releaseedition%'}',if(%releasetype%,%album% '{'%releasetype'}',if(%releaseedition% %releasetype%,%album% '{'%releaseedition% %releasetype%'}',%album%)))

If you don't want to find all your syntax errors for the formula
$if(x,y,z) = if x is true, y is returned, otherwise z.
you can try to make 3 much easier, single actions.

But first you have to explain what do you want to do exactly?
If your temporary tag %releaseedition% is filled, then you want to fill the official tag %album% with the content of {%releaseedition%} (inlcuding curly brackets)?

The first two if statements work correctly, it's the third that is this issue.
if(%releaseedition% %releasetype%,%album% '{'%releaseedition% %releasetype%'}',%album%)

I am trying to test if both %releaseedition% and %releasetype% tags exist then append them to the Album tag in curly braces.

Desired outcomes:

AlbumTitle {Deluxe}, AlbumTitle {Single} or AlbumTitle {Deluxe Single}.

Something like
if($and(%releaseedition%, %releasetype%),%album% '{'%releaseedition% %releasetype%'}',%album%)

Boolean functions:
$and(x,y) -> returns true if x and y are true

if(,Heroes (We Could Be) {Deluxe Single},Heroes (We Could Be))

Copy & paste your line 1= into an editor like notepad++ and break the lines like

$if(%releaseedition%,%album% '{'%releaseedition%'}',
 if(%releasetype%,   %album% '{'%releasetype'}',
 if($and(%releaseedition% , %releasetype%) ,%album% '{'%releaseedition% %releasetype%'}',%album%)))

Then re-read my first answer with the $if(x,y,z)-command

You can read your 3 lines above like:
IF %releaseedition% is true (= in this case not empty), then fill %album% with the content of {%releaseedition%}
IF %releaseedition% is false (= in this case empty), then check this:
IF %releasetype% is true (= in this case not empty), then fill %album% with the content of {%releasetype%}

if you complete the $if(x,y,z) logic for OTHERWISE Z
In which case will your 3rd IF-condition ever be reached and executed?

I've decided to separate each statement into individual actions. The previous reply is the result of the if $and statement only.

Did you forget the leading dollar sign $ in front of the IF-condition if you use it as individual action?

$if($and(%releaseedition% , %releasetype%) ,%album% '{'%releaseedition% %releasetype%'}',%album%)
which reads:
IF both %releaseedition% AND %releasetype% are true (= in this case not empty), then fill %album% with the content of {%releaseedition% SPACE %releasetype%}
IF one of %releaseedition% OR %releasetype% are false (= in this case empty), then let %album% remain unchanged

Oops, my bad. Thanks :slight_smile:

1 Like

Another way is to use the power of square brackets in the format string, like this:
$Replace(%album% [ {%releaseedition% %releasetype%}],{ ,{, },})

See here: Characters with special functionality

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.