I have some data that contains an ID and a TYPE and then some measures that are displayed in a barchart.
The data looks like this:
ID TYPE MEASURE
600 A 36,2
600 B 12,8
700 A 18,0
700 B 44,4
...
To filter the barchart I have a select-list for the ID and buttonbar for the TYPE (A and B).
I now want to have a specific default value for the button bar that depends on the ID.
So that say the ID is 600 then the TYPE-button should have A selected but if I choose 700 then the B-button should be selected.
This pairing comes from a lookup-table that I have joined with my data so there is now a TYPE_DEFAULT column as well.
ID TYPE TYPE_DEFAULT MEASURE
600 A A 36,2
600 B A 12,8
700 A B 18,0
700 B B 44,4
...
The only way to control what item in the button bar is highlighted/selected seems to be to select that the "first" item should be highlighted/selected.
I figured it was ok if the order of A and B switched depending on the selected ID so my plan was to dynamically change the order.
I therefore renamed TYPE to TYPE A-B and set a custom sort on it so that A comes before B.
I then cloned that variable, called it TYPE B-A and set a custom sort on that where B comes before A.
I then created a calculated item A-B-A that says
IF ( 'TYPE_DEFAULT'n = 'A' )
RETURN 'TYPE A-B'n
ELSE 'TYPE B-A'n
I then set the button bar to use the calculated A-B-A -variable instead, but it doesn't work. When I select an ID in the dropdown list that is associated with the default value A, the button bar doesn't switch the order of the buttons.
However if I assign the TYPE A-B variable directly to the button bar, then the A-button comes first and is highlighted. The same the other way around so if I assign TYPE B-A, the B-button comes first and is highlighted.
So obviously the calculated item doesnt inherit the sort order of the variable it returns and my solution is a fail.
Can someone think of another solution?
Many thanks