<?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 Syntax Question in Macro in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Syntax-Question-in-Macro/m-p/159875#M34353</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Consider referring to the variable inside your expression to make the value different depending on your unit-of-measure variable.&lt;/P&gt;&lt;P&gt;For example, something like: if(vCasesPounds='Pounds' ,qty * wt_per_case, qty)&lt;/P&gt;&lt;P&gt;You might want to also reference the variable in an expression for the column title so the that the title says "Quantity in Pounds" or "Quantity in Cases" depending on the value of your variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Oct 2010 22:14:59 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-10-27T22:14:59Z</dc:date>
    <item>
      <title>Syntax Question in Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Syntax-Question-in-Macro/m-p/159873#M34351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a macro that hides or shows Expressions in a chart depending on what options a user selects from an InputBox. It works fine but I need to know if it's possible to reference the expressions by name rather than by "Item(3)". My users may change the order of the Expressions in the chart and I need to make sure the proper Expressions are acted upon regardless of their order.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;BR /&gt;sub CasesorPounds&lt;BR /&gt;&lt;BR /&gt;vSelection = ActiveDocument.Variables("vCasesPounds").GetContent.String&lt;BR /&gt;&lt;BR /&gt;set vChart1 = ActiveDocument.GetSheetObject("CH04")&lt;BR /&gt;set vCP1 = vChart1.GetProperties&lt;BR /&gt;set vCP1Expression3 = vCP1.Expressions.Item(3).Item(0).Data.ExpressionData&lt;BR /&gt;set vCP1Expression4 = vCP1.Expressions.Item(4).Item(0).Data.ExpressionData&lt;BR /&gt;set vCP1Expression5 = vCP1.Expressions.Item(5).Item(0).Data.ExpressionData&lt;BR /&gt;set vCP1Expression6 = vCP1.Expressions.Item(6).Item(0).Data.ExpressionData&lt;BR /&gt;set vCP1Expression7 = vCP1.Expressions.Item(7).Item(0).Data.ExpressionData&lt;BR /&gt;set vCP1Expression8 = vCP1.Expressions.Item(8).Item(0).Data.ExpressionData&lt;BR /&gt;&lt;BR /&gt;select case vSelection&lt;BR /&gt; case "Cases"&lt;BR /&gt; vCP1Expression3.Enable=true&lt;BR /&gt; vCP1Expression4.Enable=true&lt;BR /&gt; vCP1Expression5.Enable=false&lt;BR /&gt; vCP1Expression6.Enable=false&lt;BR /&gt; vCP1Expression7.Enable=true&lt;BR /&gt; vCP1Expression8.Enable=false&lt;BR /&gt; case "Pounds"&lt;BR /&gt; vCP1Expression3.Enable=false&lt;BR /&gt; vCP1Expression4.Enable=false&lt;BR /&gt; vCP1Expression5.Enable=true&lt;BR /&gt; vCP1Expression6.Enable=true&lt;BR /&gt; vCP1Expression7.Enable=false&lt;BR /&gt; vCP1Expression8.Enable=true&lt;BR /&gt; case "Both"&lt;BR /&gt; vCP1Expression3.Enable=true&lt;BR /&gt; vCP1Expression4.Enable=true&lt;BR /&gt; vCP1Expression5.Enable=true&lt;BR /&gt; vCP1Expression6.Enable=true&lt;BR /&gt; vCP1Expression7.Enable=true&lt;BR /&gt; vCP1Expression8.Enable=true&lt;BR /&gt;end select&lt;BR /&gt;&lt;BR /&gt;vChart1.SetProperties vCP1&lt;BR /&gt;&lt;BR /&gt;end sub&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Oct 2010 19:40:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Syntax-Question-in-Macro/m-p/159873#M34351</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-10-26T19:40:35Z</dc:date>
    </item>
    <item>
      <title>Syntax Question in Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Syntax-Question-in-Macro/m-p/159874#M34352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't believe there is a way to reference expressions by name. I agree that referencing them by order is severly limited. I've pretty much given up on expression based macros like this because of it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Oct 2010 20:18:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Syntax-Question-in-Macro/m-p/159874#M34352</guid>
      <dc:creator />
      <dc:date>2010-10-26T20:18:25Z</dc:date>
    </item>
    <item>
      <title>Syntax Question in Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Syntax-Question-in-Macro/m-p/159875#M34353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Consider referring to the variable inside your expression to make the value different depending on your unit-of-measure variable.&lt;/P&gt;&lt;P&gt;For example, something like: if(vCasesPounds='Pounds' ,qty * wt_per_case, qty)&lt;/P&gt;&lt;P&gt;You might want to also reference the variable in an expression for the column title so the that the title says "Quantity in Pounds" or "Quantity in Cases" depending on the value of your variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Oct 2010 22:14:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Syntax-Question-in-Macro/m-p/159875#M34353</guid>
      <dc:creator />
      <dc:date>2010-10-27T22:14:59Z</dc:date>
    </item>
    <item>
      <title>Syntax Question in Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Syntax-Question-in-Macro/m-p/159876#M34354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Tim. I would've done it that way except that the users may want to see both Pounds and Cases at the same time. So hiding/showing expressions was the way I went.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Oct 2010 23:24:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Syntax-Question-in-Macro/m-p/159876#M34354</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-10-27T23:24:34Z</dc:date>
    </item>
    <item>
      <title>Syntax Question in Macro</title>
      <link>https://community.qlik.com/t5/QlikView/Syntax-Question-in-Macro/m-p/159877#M34355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may already think about this (a bit crude and may affect performance). What if you create a procedure which loops thru the expression and disabling or enabling it as necessary. Something like&lt;/P&gt;&lt;P&gt;public sub EnableDisableExpression(pExpression, pFlag)&lt;BR /&gt; set vChart1 = ActiveDocument.GetSheetObject("CH01")&lt;BR /&gt; set vCP1 = vChart1.GetProperties&lt;BR /&gt; iNumExpr = vCP1.Expressions.count&lt;BR /&gt;&lt;BR /&gt; for iCtr = 0 to iNumExpr - 1&lt;BR /&gt; if vCP1.Expressions.Item(iCtr).Item(0).Data.ExpressionData.Definition.v = pExpression then&lt;BR /&gt; vCP1.Expressions.Item(iCtr).Item(0).Data.ExpressionData.Enable = pFlag&lt;BR /&gt; exit for&lt;BR /&gt; end if&lt;BR /&gt; next&lt;BR /&gt; vChart1.SetProperties vCP1&lt;BR /&gt;end sub&lt;/P&gt;&lt;P&gt;Then on your if then statement you call the routing like&lt;/P&gt;&lt;P&gt;if Cases then&lt;/P&gt;&lt;P&gt;EnableDisableExpression "=sum(field1)", "false"&lt;/P&gt;&lt;P&gt;EnableDisableExpression "=sum(field2)", "true"&lt;/P&gt;&lt;P&gt;end if&lt;/P&gt;&lt;P&gt;if Pounds then&lt;/P&gt;&lt;P&gt;EnableDisableExpression "=sum(field1)", "true"&lt;/P&gt;&lt;P&gt;EnableDisableExpression "=sum(field1)", "false"&lt;/P&gt;&lt;P&gt;end if&lt;/P&gt;&lt;P&gt;i hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Oct 2010 07:41:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Syntax-Question-in-Macro/m-p/159877#M34355</guid>
      <dc:creator />
      <dc:date>2010-10-28T07:41:36Z</dc:date>
    </item>
  </channel>
</rss>

