Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
HDbrpJA8E4
Contributor
Contributor

Programmatically change alternate state values

Hi,

I have an app where the user chooses an machine and a year from an filter pane and i show him different performance values.

i have one diagram where i show him the data per calendar week and one where the whole year is summarised. 

Now i want to add another diagram where i show him the summarised values for the last year.

Screenshot 2021-01-22 084817.png

What i did was to create an alternate state and that would work fine. Problem is usability.

  • If an user selects a year, i want to automatically change the value in the alternate state to the last year.
  • If a user selects a machine, it should do so also in the alternate_state. 
    • i would have the possibility to only work with the default state, but not when the field has the property "Always one selected value"
      • I still could only work with the default state, but it gets so confusing in the filter.

Is there a way to programmatically change the values in the alternate state when the values change in the default state? 

Or is there another way simpler solution?

Thanks

5 Replies
edwin
Master II
Master II

you dont need alternating states for this, you can use set analysis:

{<... YEAR={$(=only(YEAR)-1)}...>}

HDbrpJA8E4
Contributor
Contributor
Author

Hi thanks, got it.
But now i have another issue.

I did define my Measures, with colours and everything,  like this:

(sum(made_pieces)/sum(productive_duration_sec))*3600

But now i need another measure for the previous year:

(sum({<booking_isoyear={$(=booking_isoyear-1)}>}made_pieces)/sum({<booking_isoyear={$(=booking_isoyear-1)}>}productive_duration_sec))*3600

 Do i have another option than to define every Measure twice? 

jyothish8807
Master II
Master II

You will have to modify all the expressions where you want to show last year value. Better would be you create a variable and use that is all your expression, so next time if you want to change from last year to previous 2 year , you can simply achieve that by modifying the variable. Like this:

vPreviousYear = Year(Max(booking_isoyear))-1

(sum({<booking_isoyear={$(vPreviousYear )}>}made_pieces)/sum({<booking_isoyear = {$(vPreviousYear)}>}productive_duration_sec))*3600

Best Regards,
KC
HDbrpJA8E4
Contributor
Contributor
Author

Hi,

thanks for your answer. I made it as you said and everything is working fine. However, i do not really like this solution as i have to define the same Measure twice.

I do still think working with alternate states would be the cleanest solution, if it would be possible to trigger an change somehow.

I keep it open in the meantime, maybe someone else comes up with a different solution.

Best Regards

edwin
Master II
Master II

if you want to use alt states, you can specify the state when you are adding your triggers.  you first define your alt state in doc settings, then in field triggers:

edwin_0-1611672405940.png