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: 
n1ef5ng1
Creator
Creator

Any wrong with my code in alternate state?

I am using alternate state namely : Group 1 and Group 2. Am i able to use set analysis on values that is group under 1 and 2?

I am creating a valuelist Barchart to have the customized X axis

Dimension of bar chart

 

=ValueList('LADEN','EMPTY')

Expression of bar chart

A=

if(ValueList('LADEN','EMPTY') = 'LADEN',
sum({[Group 1]<Derived_Container_Class_Name={'LADEN'}>}TEU),
if(ValueList('LADEN','EMPTY') = 'EMPTY',
sum({[Group 1]<Derived_Container_Class_Name={'EMPTY'}>}TEU)))

B=

if(ValueList('LADEN','EMPTY') = 'LADEN',
sum({[Group 2]<Transit_Container_Class={'F'}>}Transit_TEU),
if(ValueList('LADEN','EMPTY') = 'EMPTY',
sum({[Group 2]<Transit_Container_Class={'E'}>}Transit_TEU)))

it seems that the value does  not change, any wrrong with my code, thanks

7 Replies
sujeetsingh
Master III
Master III

Ben can you provide the sample

Sokkorn
Master
Master

Hi Bennn,

Your expression look ok. Which list box use alternate state? Or possible attached your file here?

Regards,

Sokkorn

n1ef5ng1
Creator
Creator
Author

I really hope I can give the sample file... I guess I might have to recreate with dummy data. Ok If I can give screenshot?
My code

 

=

if(ValueList('LADEN','EMPTY') = 'LADEN',
sum({[Group 1]<Derived_Container_Class_Name={'LADEN'}>}TEU),
if(ValueList('LADEN','EMPTY') = 'EMPTY',

as you can see from the selection and table name A, i seleted Throughput A EMPTY but it shows data for Laden and Empty. The data seems fix no matter what selection i choose on the selection box. Figures shown on the graph are all wrong....


sum({[Group 1]<Derived_Container_Class_Name={'EMPTY'}>}TEU)))

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

The alternate states refer to selections made in that state, such as in a list box set to that state. I am not sure what you are trying to achieve with this expression, but I think the states are superfluous and possibly breaking your logic. Try the expressions without states.

Have you applied states to the tab containing this chart or to the chart object itself?

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
n1ef5ng1
Creator
Creator
Author

I agree. I have tried to select other fields and it seems that it is working. it seems that there is a conflict when I choose Container Status on panel box when my code is already defined for this. so sorry about it, haha. IT SEEMS WORKING!!! haha thanks everyone

n1ef5ng1
Creator
Creator
Author

I have decided not to use Valuelist as it might be difficult to maintain,

Instead I have put it on the dimension in this way

 

=

if(Derived_Container_Class_Name='LADEN' or Transit_Container_Class = 'F','LADEN'
,
if(Derived_Container_Class_Name = 'EMPTY' or Transit_Container_Class='E','EMPTY')
)

However, I have Database A that has Country and Database B that has Transit_Country.

Instead of listing out all the country saying if(Country = Indonesia or Transit_Country - Indonesia','Indonesia',)is there any shortcut ways that they will do matching by themself and call the specific name?

this will help greatly

greg-anderson
Luminary Alumni
Luminary Alumni

While your script looks okay per se, it does appear that you could simplify some of these comparisons by doing the data manipulation in the load script and assigning variables to some of the items that are being used for comparison.