<?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 Re: API visualisation.create : barchart : sort by measure in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/API-visualization-create-barchart-sort-by-measure/m-p/2132544#M19380</link>
    <description>&lt;P&gt;Good to know this! Basically in this way is just overriding the single property (qInterColumnSortOrder) instead of the entire HyperCubeDef.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Oct 2023 15:53:48 GMT</pubDate>
    <dc:creator>alex_colombo</dc:creator>
    <dc:date>2023-10-27T15:53:48Z</dc:date>
    <item>
      <title>API visualization.create : barchart : sort by measure</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/API-visualization-create-barchart-sort-by-measure/m-p/2132429#M19376</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am creating visualizations on the fly with the Capability APIs / Visualization API&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense-developer/August2023/Subsystems/APIs/Content/Sense_ClientAPIs/CapabilityAPIs/VisualizationAPI/create-method.htm" target="_blank" rel="noopener"&gt;https://help.qlik.com/en-US/sense-developer/August2023/Subsystems/APIs/Content/Sense_ClientAPIs/CapabilityAPIs/VisualizationAPI/create-method.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;It seems there is no way to sort a barchart by measure value.&lt;/P&gt;
&lt;P&gt;All the options are documented here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense-developer/August2023/Subsystems/APIs/Content/Sense_ClientAPIs/CapabilityAPIs/VisualizationAPI/barchart-properties.htm" target="_blank" rel="noopener"&gt;https://help.qlik.com/en-US/sense-developer/August2023/Subsystems/APIs/Content/Sense_ClientAPIs/CapabilityAPIs/VisualizationAPI/barchart-properties.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;When I create the graph manually in a Qlik app , and then inspect the hypercube Qlik has generated, I can see there is a parameter "qInterColumnSortOrder" to specify the sort order of the different dimensions and measures.&lt;/P&gt;
&lt;P&gt;By ex, in a barchart with one dimension and one measure, if the measure is first in sorting order,&amp;nbsp;qInterColumnSortOrder&amp;nbsp; is set to [1,0]&lt;/P&gt;
&lt;P&gt;But this parameter has no impact when using the API visualization.create()&lt;/P&gt;
&lt;P&gt;Could you please advice if this is possible and how to do it ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 13:33:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/API-visualization-create-barchart-sort-by-measure/m-p/2132429#M19376</guid>
      <dc:creator>ExtensionMaster</dc:creator>
      <dc:date>2023-11-09T13:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: API visualisation.create : barchart : sort by measure</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/API-visualization-create-barchart-sort-by-measure/m-p/2132538#M19378</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/133883"&gt;@ExtensionMaster&lt;/a&gt;&amp;nbsp;, for changing the sort order you have to use the&amp;nbsp;&lt;EM&gt;qHyperCubeDef&amp;nbsp;&lt;/EM&gt;option, and this means that you have to pass the entire barchart HyperCube definition, in which you can find&amp;nbsp;&lt;SPAN&gt;qInterColumnSortOrder property.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Below you can find an example where I'm creating a viz on the fly passing the qHyperCubeDef option. For keeping things simple, I'm reusing an HypercubeDef from an existing barchart, very similar to the one I'm creating on the fly. In your scenario, you can save somewhere the HyperCubeDef for a barchart, and then use it for you visualizations on the fly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;let hyperCubeDef;
app.visualization.get('QssGsxc').then(function(viz) {
	//Get HyperCubeDef from existing viz
	const vizProps = viz.model.getFullPropertyTree().then(function(props) {
		//Save current hyperCubeDef
		hyperCubeDef = props.qProperty.qHyperCubeDef
		
		//Change sort order
		hyperCubeDef.qInterColumnSortOrder = [1,0,2];
		
		//Create viz on the fly based on hypercube of another viz
		app.visualization.create('barchart',["Dim1","=Sum(Expression1)","=Sum(Expression2)"],{qHyperCubeDef: hyperCubeDef}).then(function(bar){
			bar.show('QV02');
		});
	})
});&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 15:38:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/API-visualization-create-barchart-sort-by-measure/m-p/2132538#M19378</guid>
      <dc:creator>alex_colombo</dc:creator>
      <dc:date>2023-10-27T15:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: API visualisation.create : barchart : sort by measure</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/API-visualization-create-barchart-sort-by-measure/m-p/2132543#M19379</link>
      <description>&lt;P&gt;Hi Alex,&lt;/P&gt;
&lt;P&gt;Very good, this is working, thank you !&lt;/P&gt;
&lt;P&gt;My mistake was to set the qInterColumnSortOrder at the top level of the options, but it needs to be inside the qHyperCubeDef property.&lt;/P&gt;
&lt;P&gt;In fact I don't need to copy the hypercube of another object, just set the property like this :&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;const dimAndMeasures = []; // fill the list

const options = {};
options.qHyperCubeDef = {};
options.qHyperCubeDef.qInterColumnSortOrder = [1, 0];
app.visualization.create('barchart', dimAndMeasures, options)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 15:51:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/API-visualization-create-barchart-sort-by-measure/m-p/2132543#M19379</guid>
      <dc:creator>ExtensionMaster</dc:creator>
      <dc:date>2023-10-27T15:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: API visualisation.create : barchart : sort by measure</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/API-visualization-create-barchart-sort-by-measure/m-p/2132544#M19380</link>
      <description>&lt;P&gt;Good to know this! Basically in this way is just overriding the single property (qInterColumnSortOrder) instead of the entire HyperCubeDef.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 15:53:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/API-visualization-create-barchart-sort-by-measure/m-p/2132544#M19380</guid>
      <dc:creator>alex_colombo</dc:creator>
      <dc:date>2023-10-27T15:53:48Z</dc:date>
    </item>
  </channel>
</rss>

