Qlik Community

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Support Case Portal has moved to Qlik Community! Read the FAQs to start exploring Support resources.
cancel
Showing results for 
Search instead for 
Did you mean: 
robertsb41
Contributor II
Contributor II

Calculate Measure and Alternate State in Same Expression

Hello,

I'm using a line chart to show data points for multiple alternate states. For each measure I need to include the alternate state in the expression.  I want to sum(sales) only if they were ([Rank]=1) and use the "Company 1" alternate state. 

sum({$<Rank={1},"Company 1">}Sales) - Tried this but no luck.  Also tried If Then statement with no luck.

Thanks in advance!

Labels (3)
1 Solution

Accepted Solutions
GaryGiles
Specialist
Specialist

Replace the $ with the Alternate State name like this:

sum({[Company 1]<Rank={1}>}Sales) 

View solution in original post

6 Replies
GaryGiles
Specialist
Specialist

Replace the $ with the Alternate State name like this:

sum({[Company 1]<Rank={1}>}Sales) 

View solution in original post

robertsb41
Contributor II
Contributor II
Author

Perfect!  This community is great.  Now what if I wanted to use the company selection as the label name in the chart?

=' '&GetCurrentSelections(chr(13)&chr(10), '=', ',' ,9,'Company 1')

I tried that but it puts the name of the dimension in front of the company name.

 

GaryGiles
Specialist
Specialist

Not sure I follow how the expression you posted is working.

You may want to try GetFieldSelections(FieldName) or wrap the whole thing with a Replace function to replace 'Company=' with ''.

robertsb41
Contributor II
Contributor II
Author

Think I resolved the label issue by using:

=Only ({'Company 1'} Name_Bidder)

But the label now shows up as - which is better than where I was at before.  Is there a way for making the label not show unless a selection is made from the alternate state?

Thanks for answering my first question, it got me on the right path.  I will update as Solved.

robertsb41
Contributor II
Contributor II
Author

I should clarify, it shows a dash if there isn't a selection.  The company name shows once a selection is made.  I want the label not to show if no selection is made ie get rid of the dash.

GaryGiles
Specialist
Specialist

Try this:

=if(GetSelectedCount(Name_Bidder,True(),'Group 1')>0,Only ({'Company 1'} Name_Bidder),'')