Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Label Names

Hi All

I written some code to change a field name depending on the criteria selected.

There are two fields if only one is selected the code works fine, however if both are selected one field name is left blank.

This is my code

=if("Scenario_Desc"='FULL YEAR BUDGET','Annual Budget',

    if("Scenario_Desc"='CUMULATIVE BUDGETS','Budget To Date',''))

=if("Scenario_Desc"='YEAR END FORECAST','Year End Forecast',

    if("Scenario_Desc"='CUMULATIVE ACTUALS','Actual To Date',''))

I want what was the Budget Column to say Annual Budget or Budget To Date depending on what is selected and similarly for what was the actual column.

I've attached a picture with lines showing what I want where.

Hope this makes sense.

Thanks for your continued help.

6 Replies
lironbaram
Partner - Master III
Partner - Master III

hi if you want to be able to change the budget column name and actual

each one by a different selection ,

then you need to create to separate fields

because as of right now if you only select "CUMULATIVE ACTUALS"

then the budget expression returns null because both if statements aren't true

the other option is to create one field with the values : Actual , Forecast

and then your expressions will look lik this

=if("Scenario_Desc"='Forecast','Annual Budget',

    if("Scenario_Desc"='Actual','Budget To Date',''))

=if("Scenario_Desc"='Forecast','Year End Forecast',

    if("Scenario_Desc"='Actual','Actual To Date',''))

Not applicable
Author

Hi Andrew,

Another option you have is to use concat and index to deal with multiple selections.

=If(Index( Concat([Scenario_Desc]),'FULL YEAR BUDGET')>0, 'Annual Budget',

    if(Index( Concat([Scenario_Desc]),'CUMULATIVE BUDGETS')>0,'Budget To Date',''))

something like that

hope that helps

Joe

Not applicable
Author

Hi Joe & Liron

Thanks for the replys.

Both options work if I select one Scenario Description, however I get blanks if two are selected.

In the example I attached the user must select

One of 'FULL YEAR BUDGET' or ,'CUMULATIVE BUDGETS'

and one of 'YEAR END FORECAST' or 'CUMULATIVE ACTUALS'

So both columns should always have a description.

Thanks

Not applicable
Author

Hi Andrew,

the above works for multiple selections, looks like 'Business Stream' has no budget and that is what is causing the problem.

Just need to modify slightly to ignore that selection

=If(Index( Concat({<[Business Stream]=>} [Scenario_Desc]),'FULL YEAR BUDGET')>0, 'Annual Budget',

    if(Index( Concat({<[Business Stream]=>} [Scenario_Desc]),'CUMULATIVE BUDGETS')>0,'Budget To Date',''))

morganaaron
Specialist
Specialist

Hi Andrew,

Try using:

=If(Index(GetFieldSelections(Scenario_Desc), 'FULL YEAR BUDGET'), 'Full Year Budget',

If(Index(GetFieldSelections(Scenario_Desc), 'CUMULATIVE BUDGETS'), 'Budget To Date',))

For the Budgets one, and the same but with the two field values for Actual, and it should work.

Not applicable
Author

This works better actually Andrew, I would go with it, doesn't matter what other selections you make then apart from Business Stream.