<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Dynamically change the selected value of a button? in SAS Visual Analytics</title>
    <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Dynamically-change-the-selected-value-of-a-button/m-p/959478#M18642</link>
    <description>&lt;P&gt;I have some data that contains&amp;nbsp; an ID and a TYPE and then some measures that are displayed in a barchart.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data looks like this:&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TYPE&amp;nbsp; &amp;nbsp;MEASURE&lt;BR /&gt;600&amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;36,2&lt;BR /&gt;600&amp;nbsp; &amp;nbsp; B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12,8&lt;BR /&gt;700&amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 18,0&lt;BR /&gt;700&amp;nbsp; &amp;nbsp; B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;44,4&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;To filter the barchart I have a select-list for the ID and buttonbar for the TYPE (A and B).&lt;BR /&gt;I now want to have a specific default value for the button bar that depends on the ID.&lt;BR /&gt;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.&lt;BR /&gt;This pairing comes from a lookup-table that I have joined with my data so there is now a TYPE_DEFAULT column as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TYPE&amp;nbsp; &amp;nbsp;TYPE_DEFAULT&amp;nbsp; &amp;nbsp;MEASURE&lt;BR /&gt;600&amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;36,2&lt;BR /&gt;600&amp;nbsp; &amp;nbsp; B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12,8&lt;BR /&gt;700&amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18,0&lt;BR /&gt;700&amp;nbsp; &amp;nbsp; B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 44,4&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;I therefore renamed TYPE to TYPE A-B and set a custom sort on it so that A comes before B.&lt;BR /&gt;I then cloned that variable, called it TYPE B-A and set a custom sort on that where B comes before A.&lt;BR /&gt;I then created a calculated item A-B-A that says&lt;BR /&gt;&lt;BR /&gt;IF ( 'TYPE_DEFAULT'n = 'A' )&lt;BR /&gt;RETURN 'TYPE A-B'n&lt;BR /&gt;ELSE 'TYPE B-A'n&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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&amp;nbsp;TYPE B-A, the B-button comes first and is highlighted.&lt;BR /&gt;&lt;BR /&gt;So obviously the calculated item doesnt inherit the sort order of the variable it returns and my solution is a fail.&lt;BR /&gt;&lt;BR /&gt;Can someone think of another solution?&lt;BR /&gt;&lt;BR /&gt;Many thanks&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Feb 2025 12:15:04 GMT</pubDate>
    <dc:creator>andypandy_swe</dc:creator>
    <dc:date>2025-02-18T12:15:04Z</dc:date>
    <item>
      <title>Dynamically change the selected value of a button?</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Dynamically-change-the-selected-value-of-a-button/m-p/959478#M18642</link>
      <description>&lt;P&gt;I have some data that contains&amp;nbsp; an ID and a TYPE and then some measures that are displayed in a barchart.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data looks like this:&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TYPE&amp;nbsp; &amp;nbsp;MEASURE&lt;BR /&gt;600&amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;36,2&lt;BR /&gt;600&amp;nbsp; &amp;nbsp; B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12,8&lt;BR /&gt;700&amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 18,0&lt;BR /&gt;700&amp;nbsp; &amp;nbsp; B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;44,4&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;To filter the barchart I have a select-list for the ID and buttonbar for the TYPE (A and B).&lt;BR /&gt;I now want to have a specific default value for the button bar that depends on the ID.&lt;BR /&gt;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.&lt;BR /&gt;This pairing comes from a lookup-table that I have joined with my data so there is now a TYPE_DEFAULT column as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TYPE&amp;nbsp; &amp;nbsp;TYPE_DEFAULT&amp;nbsp; &amp;nbsp;MEASURE&lt;BR /&gt;600&amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;36,2&lt;BR /&gt;600&amp;nbsp; &amp;nbsp; B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12,8&lt;BR /&gt;700&amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18,0&lt;BR /&gt;700&amp;nbsp; &amp;nbsp; B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 44,4&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;I therefore renamed TYPE to TYPE A-B and set a custom sort on it so that A comes before B.&lt;BR /&gt;I then cloned that variable, called it TYPE B-A and set a custom sort on that where B comes before A.&lt;BR /&gt;I then created a calculated item A-B-A that says&lt;BR /&gt;&lt;BR /&gt;IF ( 'TYPE_DEFAULT'n = 'A' )&lt;BR /&gt;RETURN 'TYPE A-B'n&lt;BR /&gt;ELSE 'TYPE B-A'n&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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&amp;nbsp;TYPE B-A, the B-button comes first and is highlighted.&lt;BR /&gt;&lt;BR /&gt;So obviously the calculated item doesnt inherit the sort order of the variable it returns and my solution is a fail.&lt;BR /&gt;&lt;BR /&gt;Can someone think of another solution?&lt;BR /&gt;&lt;BR /&gt;Many thanks&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2025 12:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Dynamically-change-the-selected-value-of-a-button/m-p/959478#M18642</guid>
      <dc:creator>andypandy_swe</dc:creator>
      <dc:date>2025-02-18T12:15:04Z</dc:date>
    </item>
  </channel>
</rss>

