<?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: Macro generates chart but continously and I want once in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Macro-generates-chart-but-continously-and-I-want-once/m-p/1080841#M919480</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanku bro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 May 2016 04:06:10 GMT</pubDate>
    <dc:creator />
    <dc:date>2016-05-06T04:06:10Z</dc:date>
    <item>
      <title>Macro generates chart but continously and I want once</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-generates-chart-but-continously-and-I-want-once/m-p/1080839#M919478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i have created the macro to generate the bar chart but its generating continously and i want only once .. plz do the needful.&lt;/P&gt;&lt;P&gt;macro code:&lt;/P&gt;&lt;P&gt;Option Explicit&lt;/P&gt;&lt;P&gt;Sub GenerateBarChart()&lt;/P&gt;&lt;P&gt;Dim myChart&lt;/P&gt;&lt;P&gt;' Create a new Bar Chart&lt;/P&gt;&lt;P&gt;Set myChart = _&lt;/P&gt;&lt;P&gt;ActiveDocument.ActiveSheet().CreateBarChart()&lt;/P&gt;&lt;P&gt;' Add a dimension of Country to the new chart&lt;/P&gt;&lt;P&gt;myChart.AddDimension "COUNTRY"&lt;/P&gt;&lt;P&gt;' Add an expression&lt;/P&gt;&lt;P&gt;myChart.AddExpression "Sum(SALES) "&lt;/P&gt;&lt;P&gt;' Get the properties object&lt;/P&gt;&lt;P&gt;Dim cp&lt;/P&gt;&lt;P&gt;Set cp = myChart.GetProperties()&lt;/P&gt;&lt;P&gt;' Set the title of the dimension&lt;/P&gt;&lt;P&gt;cp.Dimensions(0).Title.v = "COUNTRY Name"&lt;/P&gt;&lt;P&gt;' Set the Title-in-chart text&lt;/P&gt;&lt;P&gt;cp.ChartProperties.Title.Title.v = "SALES by COUNTRY"&lt;/P&gt;&lt;P&gt;' Set the Window title&lt;/P&gt;&lt;P&gt;cp.GraphLayout.WindowTitle.v = "SALES $ by COUNTRY"&lt;/P&gt;&lt;P&gt;' Set sort by Y-Value&lt;/P&gt;&lt;P&gt;cp.SortByYValue = -1&lt;/P&gt;&lt;P&gt;' Get the expression properties&lt;/P&gt;&lt;P&gt;Dim expr, exprvis&lt;/P&gt;&lt;P&gt;Set expr = _&lt;/P&gt;&lt;P&gt;cp.Expressions.Item(0).Item(0).Data.ExpressionData&lt;/P&gt;&lt;P&gt;Set exprvis = _&lt;/P&gt;&lt;P&gt;cp.Expressions.Item(0).Item(0).Data.ExpressionVisual&lt;/P&gt;&lt;P&gt;' Set the Expression label&lt;/P&gt;&lt;P&gt;exprvis.Label.v = "SALES $"&lt;/P&gt;&lt;P&gt;' Set the "Values on Data Point" option&lt;/P&gt;&lt;P&gt;exprvis.NumbersOnBars = -1&lt;/P&gt;&lt;P&gt;' Set the number format for the expression&lt;/P&gt;&lt;P&gt;exprvis.NumberPresentation.Dec = "."&lt;/P&gt;&lt;P&gt;exprvis.NumberPresentation.Fmt = "#,##0.00"&lt;/P&gt;&lt;P&gt;exprvis.NumberPresentation.nDec = 2&lt;/P&gt;&lt;P&gt;exprvis.NumberPresentation.Thou = ","&lt;/P&gt;&lt;P&gt;exprvis.NumberPresentation.Type = 11 'fixed&lt;/P&gt;&lt;P&gt;exprvis.NumberPresentation.UseThou = 1&lt;/P&gt;&lt;P&gt;' Apply the modified properties&lt;/P&gt;&lt;P&gt;myChart.SetProperties cp&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Onno van Knotsenburg
Added a much more useful title (compared with "hii")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-generates-chart-but-continously-and-I-want-once/m-p/1080839#M919478</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Macro generates chart but continously and I want once</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-generates-chart-but-continously-and-I-want-once/m-p/1080840#M919479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abhishek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, you have store the created bar chart id into somewhere (Variable). Later, you can check whether a bar chart ID (created by macro) is exists or not. I have created an another sub routine which checks the whether already created bar chart id in the sheet. If yes, you will get a pop up message as "Bar chart already exists. Delete the existing one to create a new bar chart..".&amp;nbsp; If no, new bar chart will be created. See below code for better understanding!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="xml" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14624749846971178 jive_text_macro" jivemacro_uid="_14624749846971178"&gt;
&lt;P&gt;Sub BarChart&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;' Check whether stored bar chart id exists in the sheet&lt;/P&gt;
&lt;P&gt;set v = ActiveDocument.GetVariable("vVar1")&lt;/P&gt;
&lt;P&gt;set s=ActiveDocument.ActiveSheet&lt;/P&gt;
&lt;P&gt;for i=0 to s.NoOfSheetObjects-1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if s.SheetObjects(i).GetObjectId =&amp;nbsp; v.GetContent.String then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Msgbox "Bar chart already exists. Delete the existing one to create a new bar chart.."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Exit Sub&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; End if&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;next&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Call&amp;nbsp; GenerateBarChart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;End Sub&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;'======================================================================&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;Sub GenerateBarChart&lt;/SPAN&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;Dim myChart&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;' Create a new Bar Chart&lt;/P&gt;
&lt;P&gt;Set myChart = _&lt;/P&gt;
&lt;P&gt;ActiveDocument.ActiveSheet().CreateBarChart()&lt;/P&gt;
&lt;P&gt;' Reset the variable&lt;/P&gt;
&lt;P&gt;set v = ActiveDocument.GetVariable("vVar1")&lt;/P&gt;
&lt;P&gt;v.SetContent myChart.GetobjectId , true&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;' Add a dimension of Country to the new chart&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;myChart.AddDimension "COUNTRY"&lt;/P&gt;
&lt;P&gt;' Add an expression&lt;/P&gt;
&lt;P&gt;myChart.AddExpression "Sum(SALES) "&lt;/P&gt;
&lt;P&gt;' Get the properties object&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;Dim cp&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Set cp = myChart.GetProperties()&lt;/P&gt;
&lt;P&gt;' Set the title of the dimension&lt;/P&gt;
&lt;P&gt;cp.Dimensions(0).Title.v = "COUNTRY Name"&lt;/P&gt;
&lt;P&gt;' Set the Title-in-chart text&lt;/P&gt;
&lt;P&gt;cp.ChartProperties.Title.Title.v = "SALES by COUNTRY"&lt;/P&gt;
&lt;P&gt;' Set the Window title&lt;/P&gt;
&lt;P&gt;cp.GraphLayout.WindowTitle.v = "SALES $ by COUNTRY"&lt;/P&gt;
&lt;P&gt;' Set sort by Y-Value&lt;/P&gt;
&lt;P&gt;cp.SortByYValue = -1&lt;/P&gt;
&lt;P&gt;' Get the expression properties&lt;/P&gt;
&lt;P&gt;Dim expr, exprvis&lt;/P&gt;
&lt;P&gt;Set expr = cp.Expressions.Item(0).Item(0).Data.ExpressionData&lt;/P&gt;
&lt;P&gt;Set exprvis = cp.Expressions.Item(0).Item(0).Data.ExpressionVisual&lt;/P&gt;
&lt;P&gt;' Set the Expression label&lt;/P&gt;
&lt;P&gt;exprvis.Label.v = "SALES $"&lt;/P&gt;
&lt;P&gt;' Set the "Values on Data Point" option&lt;/P&gt;
&lt;P&gt;exprvis.NumbersOnBars = -1&lt;/P&gt;
&lt;P&gt;' Set the number format for the expression&lt;/P&gt;
&lt;P&gt;exprvis.NumberPresentation.Dec = "."&lt;/P&gt;
&lt;P&gt;exprvis.NumberPresentation.Fmt = "#,##0.00"&lt;/P&gt;
&lt;P&gt;exprvis.NumberPresentation.nDec = 2&lt;/P&gt;
&lt;P&gt;exprvis.NumberPresentation.Thou = ","&lt;/P&gt;
&lt;P&gt;exprvis.NumberPresentation.Type = 11 'fixed&lt;/P&gt;
&lt;P&gt;exprvis.NumberPresentation.UseThou = 1&lt;/P&gt;
&lt;P&gt;' Apply the modified properties&lt;/P&gt;
&lt;P&gt;myChart.SetProperties cp&lt;/P&gt;
&lt;P&gt;End Sub&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached a sample file. If you have any issues, let me know.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 May 2016 19:15:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-generates-chart-but-continously-and-I-want-once/m-p/1080840#M919479</guid>
      <dc:creator>tamilarasu</dc:creator>
      <dc:date>2016-05-05T19:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: Macro generates chart but continously and I want once</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-generates-chart-but-continously-and-I-want-once/m-p/1080841#M919480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanku bro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 May 2016 04:06:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-generates-chart-but-continously-and-I-want-once/m-p/1080841#M919480</guid>
      <dc:creator />
      <dc:date>2016-05-06T04:06:10Z</dc:date>
    </item>
  </channel>
</rss>

