Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
sibrulotte
Creator III
Creator III

Alternate states: Using default state in list box residing in another state

Hi,

I have a listbox with a period that is in an alternate state "Comparative". An expression should show the end of the period date (I call it DATE FIN PERIODE), but that will depend on a selection done in the default state for the company name.

In the picture attached, the left box is in the default state, the right is in Comparative state. The selection done on the company name is in the default state, so the comparative box doesn't know what company we're in, hence, doesn't know what's the end of the period date.

How do I go about doing this ? Do I have to create a state for pretty much 95% of my objects (currently Inherited or default I guess) that will now be named so I can use something like this:

  In my expression of the listbox residing in the Alternate state "Comparative", define as so:

=Only({NEW STATE NAME GOES HERE}DATE_FIN_PERIODE)

I would love to find another way!!

Or I guess if I name a new state and give it to sheets, leave the rest inherited, that wouldn't impact much of the objects since they are all inherited...

Please let me know if that was not clear. I will be doing some thinking on this.

Thank you

9 Replies
jerem1234
Specialist II
Specialist II

If you are looking to apply the Company selection in the default state to the new state, set analysis like:

{<Company = $::Company>}

might come in handy. Not entirely sure of your situation, but this seems like it would help.

Maybe:

Only({<Company = $::Company>}DATE_FIN_PERIODE)


for your listbox expression in the Comparative state.


Hope this helps!

sibrulotte
Creator III
Creator III
Author

I'll mark is as usefull, but it doesn't work

= Only({<NOM_COMPAGNIE = $::NOM_COMPAGNIE>}DATE_FIN_PERIODE)

you did get the whole essence of the question Jeremy, that's exactly what I am looking to do, take the Nom_COMPAGNIE from the default state, and use it in the comparative state.

Anybody else want to take a wack?

Not applicable

Hi Simon,

Please try this,

= Only({<NOM_COMPAGNIE =p({$} NOM_COMPAGNIE * p({State1}  NOM_COMPAGNIE_>}DATE_FIN_PERIODE)

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Simon,

The function only cannot work by itself, because it will ONLY return a single value when ONLY a single value is available (no pun intended). In order to use ONLY() in a list box, it needs to be included in a function AGGR, with the same field used as a dimension. Then, for each value of  DATE_FIN_PERIODE there is ONLY one possible value, and it's going to be returned to the AGGR function:


     AGGR( only(DATE_FIN_PERIODE), DATE_FIN_PERIODE)


Now, using ONLY inside of AGGR gives you the opportunity to alter the incoming data set using Set Analysis. In your case, if you want the available Periods to be driven by the default State, but the selections to be affecting the alternate State, you can assign the List box to the Alternate State, but use the Default state and the Set ID in your Set Analysis:


     AGGR( only({$} DATE_FIN_PERIODE), DATE_FIN_PERIODE)


Or, if you'd like a mix of different conditions involving the default State vs. the Alternate State, you can qualify each field with the relevant State name.


Cheers.


Oleg Troyansky

Come and learn Advanced Set Analysis and Advanced AGGR with me at the Masters Summit in Chicago - April 1-3.

www.masterssummit.com



sibrulotte
Creator III
Creator III
Author

Although that makes alot of sense, it still doesn't work Oleg.
You also captured the essence of the question with

"want the available Periods to be driven by the default State, but the selections to be affecting the alternate State, you can assign the List box to the Alternate State, but use the Default state and the Set ID in your Set Analysis"

I have a selection done on the company name listbox (inherited, from a sheet that is also inherited, so default...).

My first listbox shows values for the DATE_FIN_PERIOD but not the comparativ state listbox. There are no other selections done.

BTW, I cam up with this in my default state listbox to make sure I get results for every row:

Only({$< [Période de paie]=>}DATE_FIN_PERIODE)

But one step at a time: I still can't get to retrieve the default state selection in my alternate state listbox.

P.S. there is ONLY one value of DATE-FIN_PERIOD for every period for a single company. Does that clarify uncertainties?

sibrulotte
Creator III
Creator III
Author

I Raja,

thanks for the try, but I have not named a "State1", and I am trying to avoid naming a default state.

sibrulotte
Creator III
Creator III
Author

Did I mention we're suppose to deploy tomorrow.

Ouch.

jerem1234
Specialist II
Specialist II

Would you be able to post a sample qvw demonstrating the problem? I would think Oleg Troyansky's solution would have worked.

If you cant post any qvw, I would test by making the same selections in the alternate state as the default state to see if it gives you the same listbox. Also you might be able to use the trigger Copy State Contents to copy the default selections to the alternate state, either to test or as a solution.

Hope this helps!

sibrulotte
Creator III
Creator III
Author

I have progressed on the matter and am looking at storing the NOM_COMPAGNIE into a variable:

There is a trigger at the field selection of NOM_COMPAGNIE that sets a variable:

  vNomcompagnie

='{'&Chr(39)&GetFieldSelections(NOM_COMPAGNIE)&Chr(39) &'}'

 

I get a lovely value that is in between single quotes and curly brackets but when I go back to my expression in the lisbox:

Only ({< NOM_COMPAGNIE= $(vNomcompagnie),[Période de paie]=>}DATE_FIN_PERIODE)

I still can't get it to retrieve anything.

That, with a set [Période de paie] at 2014-2 for example, returns a good value in a text box...

=Only({< NOM_COMPAGNIE=$(vNomcompagnie),[Période de paie]={'2014-2'}>}DATE_FIN_PERIODE)

Am getting close, if anyone has noticed an error, please let me know