Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How can 'inherited' be used for an alternate state in a variable?

Hi,

In Thread How to use a parameter in a variable to use an alternate state in set analysis I ask a question about using alternate states in variables. This question is answered and it is working for named alternate states:

The following syntax ist working:

set fTotalDuration=(sum({$1} Duration)

In the diagrams you can use the formular like =$(fTotalDuration('Machine1')).

'Machine1' is the defined alternate state.

But now I face the problem that I cannot use this formula with inherited alternate states.

That means instead of using the named alternate state 'Machine1'

I want to use the alternate state <inherited>.

So far I could not find any possibility to use <inherited> as parameter. I tried the following combinations:

  1. Variable without parameter:  =$(fTotalDuration)
  2. Variable with empty parameter:  =$(fTotalDuration(''))
  3. Variable with parameter '<inherited>':  =$(fTotalDuration('<inherited>'))
  4. Variable with parameter <inherited>:  =$(fTotalDuration(<inherited>'))
  5. Variable with parameter '$':  =$(fTotalDuration('$'))
  6. Variable with parameter $:  =$(fTotalDuration($))

So the final question remains: How can 'inherited' be used for an alternate state in a variable?

Regards

Dirk

19 Replies
sunny_talwar

I guess I see what Stefan was trying to point out... So the inherited state is inheriting the state from the sheet properties. So inherited state here is also Machine 1.... why not use Default state in that case?

antoniotiman
Master III
Master III

Hi Dirk,

I prefer to set variable

Sum($1 Duration)

and Expression

Sum(({'State'}) Duration)

or

Sum(( ) Duration

or Sum(({$}) Duration)

Regards,

Antonio

swuehl
MVP
MVP

There is a hierarchy, document level -> sheet level -> chart object level where you can set the state (well, not sure about the document state, I think it's always default state). So if you set a different alternate state on sheet level, chart objects may inherit the state (or you can explicitely define the state in chart properties).

sunny_talwar

Make sense now.... and clarify the difference between Inherited and Default state now....

Not applicable
Author

Hallo Stefan,

according to the referenced article $ indicates the default state and '' (nothing)  means inherited:

Additionally, any expression in any object can either inherit the state of the object or be controlled via set analysis. And this is the key point: sum({ $ } Sales) and  sum(Sales) now have potentially different meanings.

By hard-coding the $ in the set, we are explicitly choosing the good old-fashioned default state – all user selections. This ignores the alternate states. In fact, even if the object is assigned to an alternate state, by placing the $ in the set expression we are ignoring that alternate.

Contrast this to omitting the dollar-sign: sum(Sales) In this case we are accepting whatever state the object is in. That could be the default set $ … or it could be an alternate state, if indeed the object is assigned to an alternate state.

In that case I should omit the $-sign.

I tried this before:

  1. Variable without parameter:  =$(fTotalDuration)
  2. Variable with empty parameter:  =$(fTotalDuration(''))

But both options give me the result of 0 instead of the correct result.

I think the main question is how do the variables handle the parameter $1 and is there a parameter for 'nothing'?

set fTotalDuration=(sum({$1} Duration)

swuehl
MVP
MVP

Sum( {} Duration)

does not seem to be valid syntax. So either create a resulting expression

Sum( Duration)

to get the inherited state applied, or as I suggested above

Sum( {<DummyField>} Duration)

(Sum({<>} Duration) does not seem to be correct too..)

It's up to you how you define your variables and variable calls to end up with a valid syntax.

Not applicable
Author

Dear Stefan,

according to you explanation this will work then:

Instead of

set fTotalDuration= sum({$1} Duration)

I should use:

set fTotalDuration= if(len($1)>0, sum({$1} Duration), sum(Duration))

So the correct syntax with this formula is then:

=$(fTotalDuration('Machine1'),  when using alternate state Machine1

and

= $(fTotalDuration(''), when using the inherited state.

You are absolutely right, I have to ensure the right syntax in the variables. For me this  was not an obvious solution.

Thanks for your help.

Dirk

Not applicable
Author

So the correct syntax with this formula is then:

=$(fTotalDuration('Machine1'),  when using alternate state Machine1

and

= $(fTotalDuration(''), when using the inherited state.

dwhanand
Contributor II
Contributor II

Hi Derk

I have a dashboard with three sheets, the user asked selection of same dimension in one sheet should not affect other two sheets.

So i created three alternate state name from document properties and applied for each of the sheets.
Now i have a date range text box (action->select in field-> for a date dimension field) with logic as

  = '>=$(=date($(vStartDateNxtAD))) <=$(=date($(vEndDateNxtAD)))'  Note: i used two calendar objects and stored the value in variables

This logic worked before applying the alternate state. But after applying it stopped working i.e the charts and other associated object values in that particular sheet is not changing

The dashboard is in prod.

I tried using the variable as per the thread link

All the objects of my third dashboard sheet been changed to alternate state 'AccountDetail'

and changed the text box search logic as

= '>=$(=date($(vStartDateNxtAD('AccountDetail')))) <=$(=date($(vEndDateNxtAD('AccountDetail'))))'

Still the values are not getting changed for the date dimension (Action_due_date)


Thanks in advance