Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Talk to Experts Tuesday, Live Q&A, September 22: Moving from QlikView to Qlik Sense. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor

Force Variables to Act in Alternate States

Good morning.,

Is there a way to force a variable to act in a specific alternate state?

I want to define a variable and tell it which state to act in within the same object.  For example, salary proposals.  I'd like to be able to show the % increase of proposed salary over current salary.  Salary is defined using a variable but differs depending on the state it's in.

I would expect it to function like this: ((vSalary in AltState2 / vSalary in AltState1) - 1), where state 2 is proposed and state 1 is current.

Any suggestions would be appreciated.

Thank you,

Luke

1 Solution

Accepted Solutions
Highlighted

Try this

(vProposedSalary*(1+ Only({[AltState4]}[BonusPercent]))) / (Current_ANNUAL_SALARY*(1+Only({[AltState1]}[BonusPercent]))) - 1

View solution in original post

11 Replies
Highlighted

Why can't you use 2 variables? One for State1 and the other for the other state?

Highlighted
Contributor
Contributor

I have the individual values brought into the dashboard that way - two text objects in two alternate states. 

However, the % increase I want to show is in a single text object.  The text object itself has only one state.  Thus, that state will dictate the values brought into the function and they will be the same number (x/x=1).

Highlighted

Not sure I understand, do you mind sharing a sample to explain what you are trying to do?

Highlighted
Contributor
Contributor

This is not the full thing, but this might help:

(vProposedSalary*(1+[BonusPercent])) / (Current_ANNUAL_SALARY*(1+[BonusPercent])) - 1

Numerator: Proposed Salary + Bonus (Bonus based on the Job Title selected, Proposed Salary is an Input), info needs to be pulled from AltState4

Denominator: Current Annual Salary + Bonus (Bonus is based on the person selected), info needs to be pulled from AltState1

The whole idea is to select an associate in AltState1 and a proposed title they will be moving to in AltState4 - I want to show the % increase when bonus is taken into consideration.


If the text object is in AltState4, the proposed Job Title select in AltState4 is dictating the bonus/annual salary for the numerator and denominator.  If in AltState1, then the annual salary is correct but the bonus is dictated by the associate selected in AltState1.  If I could move the numerator into a variable and a denominator into another, and tell them which AltState to reference in the quotient, that would solve my problem.

Highlighted

Try this

(vProposedSalary*(1+ Only({[AltState4]}[BonusPercent]))) / (Current_ANNUAL_SALARY*(1+Only({[AltState1]}[BonusPercent]))) - 1

View solution in original post

Highlighted
Contributor
Contributor

This gets me what I need.  Thank you.

I have one follow up question (I'm trying now but not having much luck) to try and simplify my expressions a bit.  Can this logic be applied to a variable? e.g., Only({[Group4]}vVariableName)

Highlighted
Contributor
Contributor

Note: Group 4 = AltState4

Highlighted

What is the def. of the variable? Is it an expression or hard-coded value?

Highlighted
Contributor
Contributor

It would be either an expression or field name