<?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>Question Re: How to add script variable array to Table SAP Analytic application in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/how-to-add-script-variable-array-to-table-sap-analytic-application/qaa-p/12691844#M4762097</link>
    <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;dhiraj_gadhave&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Any script variable of type integer/number is available for use as calculation input control in Calculated measure but I do not think you would be able to use an array of type integer. &lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2168030-image.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2168032-image.png" /&gt;&lt;/P&gt;&lt;P&gt;If you use any variable of type other than number/integer you will get below warning.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2168031-image.png" /&gt; &lt;/P&gt;&lt;P&gt;Now i am able to assign a value of 5 to this script variable and measure show up accordingly&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2168033-image.png" /&gt;&lt;/P&gt;&lt;P&gt;If I make the variable as array of type integer I do not get error but nothing shows up in calculated measure (it makes sense).&lt;/P&gt;&lt;P&gt;Now if your model is a planning model you can use the API setUserInput(selectedData: &lt;A href="https://help.sap.com/doc/958d4c11261f42e992e8d01a4c0dde25/release/en-US/index.html#Selection"&gt;Selection&lt;/A&gt;, value: string):  to set the values in table.&lt;/P&gt;&lt;P&gt;So calculate your trigonometric values and then pass them to setUserInput api.&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/doc/958d4c11261f42e992e8d01a4c0dde25/release/en-US/index.html#Planning_MsetUserInput" target="test_blank"&gt;https://help.sap.com/doc/958d4c11261f42e992e8d01a4c0dde25/release/en-US/index.html#Planning_MsetUserInput&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope this helps !!&lt;/P&gt;&lt;P&gt;Please upvote/accept if this helps.&lt;/P&gt;&lt;P&gt;Nikhil&lt;/P&gt;</description>
    <pubDate>Fri, 19 May 2023 17:00:03 GMT</pubDate>
    <dc:creator>N1kh1l</dc:creator>
    <dc:date>2023-05-19T17:00:03Z</dc:date>
    <item>
      <title>How to add script variable array to Table SAP Analytic application</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-add-script-variable-array-to-table-sap-analytic-application/qaq-p/12691843</link>
      <description>&lt;P&gt;Problem Statement:- Trigonometric functions are not available in "&lt;STRONG&gt;Calculated measures&lt;/STRONG&gt;" &lt;/P&gt;
  &lt;P&gt;So I read a measure from table using Table.getDataSource().getResultSet() and calculated the new array with trigonometric functions like "Math.cos(array_1).&lt;/P&gt;
  &lt;P&gt;This calculated array is stored in new script variable.&lt;/P&gt;
  &lt;P&gt;Now How can I add this Script variable (type= Array) to the table?&lt;/P&gt;
  &lt;P&gt;Or How can I convert this Script variable (type= Array) to new Measure?&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 14:38:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-add-script-variable-array-to-table-sap-analytic-application/qaq-p/12691843</guid>
      <dc:creator>Dhiraj_G</dc:creator>
      <dc:date>2023-05-19T14:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to add script variable array to Table SAP Analytic application</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-add-script-variable-array-to-table-sap-analytic-application/qaa-p/12691844#M4762097</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;dhiraj_gadhave&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Any script variable of type integer/number is available for use as calculation input control in Calculated measure but I do not think you would be able to use an array of type integer. &lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2168030-image.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2168032-image.png" /&gt;&lt;/P&gt;&lt;P&gt;If you use any variable of type other than number/integer you will get below warning.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2168031-image.png" /&gt; &lt;/P&gt;&lt;P&gt;Now i am able to assign a value of 5 to this script variable and measure show up accordingly&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2168033-image.png" /&gt;&lt;/P&gt;&lt;P&gt;If I make the variable as array of type integer I do not get error but nothing shows up in calculated measure (it makes sense).&lt;/P&gt;&lt;P&gt;Now if your model is a planning model you can use the API setUserInput(selectedData: &lt;A href="https://help.sap.com/doc/958d4c11261f42e992e8d01a4c0dde25/release/en-US/index.html#Selection"&gt;Selection&lt;/A&gt;, value: string):  to set the values in table.&lt;/P&gt;&lt;P&gt;So calculate your trigonometric values and then pass them to setUserInput api.&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/doc/958d4c11261f42e992e8d01a4c0dde25/release/en-US/index.html#Planning_MsetUserInput" target="test_blank"&gt;https://help.sap.com/doc/958d4c11261f42e992e8d01a4c0dde25/release/en-US/index.html#Planning_MsetUserInput&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope this helps !!&lt;/P&gt;&lt;P&gt;Please upvote/accept if this helps.&lt;/P&gt;&lt;P&gt;Nikhil&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 17:00:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-add-script-variable-array-to-table-sap-analytic-application/qaa-p/12691844#M4762097</guid>
      <dc:creator>N1kh1l</dc:creator>
      <dc:date>2023-05-19T17:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to add script variable array to Table SAP Analytic application</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-add-script-variable-array-to-table-sap-analytic-application/qaa-p/12691845#M4762098</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;nikhil_1486&lt;/SPAN&gt;  Thanks for the reply, This is a very good example for using script variable in the calculated measures, I will use it .&lt;/P&gt;&lt;P&gt;The Original Problem reformatted as below: &lt;/P&gt;&lt;P&gt;I have a column B in the table with some numbers and I want to use column C as cos(column B), as Trigonometric functions are not available in calculated measures(Analytics Application) I am reading column B using onInitialization script&lt;/P&gt;&lt;P&gt;var arr = Table_5.getDataSource().getResultSet({"@MeasureDimension": "*******);&lt;/P&gt;&lt;P&gt;and then calculating the Cos function using below script&lt;/P&gt;&lt;P&gt;var value = ArrayUtils.create(Type.number);&lt;/P&gt;&lt;P&gt;var Cos = ArrayUtils.create(Type.number);&lt;/P&gt;&lt;P&gt;for (var k=0; k&amp;lt;arr.length;k++)&lt;/P&gt;&lt;P&gt;var string = arr[i][Alias.MeasureDimension].formattedValue;&lt;/P&gt;&lt;P&gt;var number = ConvertUtils.stringToNumber(string);&lt;/P&gt;&lt;P&gt;Cos[k] = Math.cos(number);&lt;/P&gt;&lt;P&gt;	}&lt;/P&gt;&lt;P&gt;And now I want to add this variable Cos ( type:Array) to the column C in the original Table., or How can I use this variable Cos as measure for other charts ?&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2023 07:54:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-add-script-variable-array-to-table-sap-analytic-application/qaa-p/12691845#M4762098</guid>
      <dc:creator>Dhiraj_G</dc:creator>
      <dc:date>2023-05-22T07:54:16Z</dc:date>
    </item>
  </channel>
</rss>

