<?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: Unexpected Token in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660511#M594290</link>
    <description>Hi Fong, I have a preceding Mapping Load of the with both the table names separately with two fields. //************This is the preceding load script*****// Product_Cost_Map: Mapping Load ProductID, NUM(CostPrice) Resident Products; //This table is already loaded with ProductID, CostPrice, SalesPrice Product_Price_Map: Mapping Load ProductID, NUM(SalesPrice) Resident Products;</description>
    <pubDate>Tue, 24 Dec 2019 14:23:12 GMT</pubDate>
    <dc:creator>AkbarShaikh</dc:creator>
    <dc:date>2019-12-24T14:23:12Z</dc:date>
    <item>
      <title>Unexpected Token</title>
      <link>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660051#M594286</link>
      <description>&lt;P&gt;Hello guys,&lt;/P&gt;&lt;P&gt;I have purchased this book Qlikview: Advanced Data Visualization and as an example, it is creating a random set of data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am scripting as per the book, but still getting an Unexpected token error. I have tried every option to resolve this, but not able to get past this error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached the script and the error message for reference.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be highly appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Akbar&lt;/P&gt;&lt;P&gt;// ***************This is the script as mentioned in the book ********************** //&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//Calculate random number of lines&lt;BR /&gt;LET vPCount = Floor(Rand () * $(vDateFactor)) + 1;&lt;/P&gt;&lt;P&gt;FOR L = 1 to $(vPCount)&lt;BR /&gt;//Calculate random values&lt;BR /&gt;LET vQty = Floor (Rand() * (50+ $(vDateFactor))) +1;&lt;BR /&gt;LET vRnd = Floor (Rand() * $(vProdCount));&lt;BR /&gt;LET vPID = Peek ('ProductID', $(vRnd), 'Product');&lt;BR /&gt;&lt;STRONG&gt;LET vCost = ApplyMap('Product_Cost_Map', $(vPID), 1);&amp;nbsp; // *****This is where the error hits in *****//&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;LET vPrice = ApplyMap('Product_Price_Map' ,$(vPID), 1);&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 19:24:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660051#M594286</guid>
      <dc:creator>AkbarShaikh</dc:creator>
      <dc:date>2024-11-16T19:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Token</title>
      <link>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660126#M594287</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;LET vCost = ApplyMap('Product_Cost_Map', &lt;STRONG&gt;&lt;EM&gt;'$(vPID)'&lt;/EM&gt;,&lt;/STRONG&gt; 1);&amp;nbsp;&lt;BR /&gt;LET vPrice = ApplyMap('Product_Price_Map' ,&lt;STRONG&gt;&lt;EM&gt;'$(vPID)'&lt;/EM&gt;,&lt;/STRONG&gt; 1);&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 13:51:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660126#M594287</guid>
      <dc:creator>Arthur_Fong</dc:creator>
      <dc:date>2019-12-23T13:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Token</title>
      <link>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660388#M594288</link>
      <description>&lt;P&gt;Thank you for the reply, I had tried using ' ' on the variable, but it still gives an error.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 07:56:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660388#M594288</guid>
      <dc:creator>AkbarShaikh</dc:creator>
      <dc:date>2019-12-24T07:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Token</title>
      <link>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660413#M594289</link>
      <description>&lt;P&gt;Applymap always go along with a mapping table.&lt;/P&gt;&lt;P&gt;Do you have a mapping table above your script?&lt;/P&gt;&lt;P&gt;Eg:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Product_Cost_Map:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Mapping load&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Key,MapField&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;inline [&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Key,MapField&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Key1,A&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Key2,B&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;];&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 09:57:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660413#M594289</guid>
      <dc:creator>Arthur_Fong</dc:creator>
      <dc:date>2019-12-24T09:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Token</title>
      <link>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660511#M594290</link>
      <description>Hi Fong, I have a preceding Mapping Load of the with both the table names separately with two fields. //************This is the preceding load script*****// Product_Cost_Map: Mapping Load ProductID, NUM(CostPrice) Resident Products; //This table is already loaded with ProductID, CostPrice, SalesPrice Product_Price_Map: Mapping Load ProductID, NUM(SalesPrice) Resident Products;</description>
      <pubDate>Tue, 24 Dec 2019 14:23:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660511#M594290</guid>
      <dc:creator>AkbarShaikh</dc:creator>
      <dc:date>2019-12-24T14:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Token</title>
      <link>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660517#M594291</link>
      <description>&lt;P&gt;Can you post the full script?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 14:36:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660517#M594291</guid>
      <dc:creator>Arthur_Fong</dc:creator>
      <dc:date>2019-12-24T14:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Token</title>
      <link>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660521#M594294</link>
      <description>&lt;P&gt;Sure Fong,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here it is...&lt;/P&gt;&lt;P&gt;//***** Script ***** //&lt;/P&gt;&lt;P&gt;//**** Generating some data ranges to be used in calculation ***** //&lt;BR /&gt;LET vStartYear = 2009;&lt;BR /&gt;LET vEndYear = Year(Now());&lt;BR /&gt;LET vStartDate = Floor(MakeDate($(vStartYear)), 4, 1);&lt;BR /&gt;LET vEndDate = Floor(MakeDate($(vEndYear)), 3, 31);&lt;BR /&gt;LET vNumDays = vEndDate - vStartDate +1;&lt;/P&gt;&lt;P&gt;Products:&lt;BR /&gt;LOAD ProductID,&lt;BR /&gt;Product,&lt;BR /&gt;CategoryID,&lt;BR /&gt;SupplierID,&lt;BR /&gt;Money# (CostPrice, '$#,##0.00', '.', ',') as CostPrice,&lt;BR /&gt;Money# (SalesPrice, '$#,##0.00', '.', ',') as SalesPrice&lt;BR /&gt;FROM&lt;BR /&gt;Products.txt&lt;BR /&gt;(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);&lt;/P&gt;&lt;P&gt;Product_Cost_Map:&lt;BR /&gt;MAPPING LOAD&lt;BR /&gt;ProductID,&lt;BR /&gt;NUM(CostPrice)&lt;BR /&gt;RESIDENT Products;&lt;/P&gt;&lt;P&gt;Product_Price_Map:&lt;BR /&gt;MAPPING LOAD&lt;BR /&gt;ProductID,&lt;BR /&gt;NUM(SalesPrice)&lt;BR /&gt;RESIDENT Products;&lt;/P&gt;&lt;P&gt;Customer:&lt;BR /&gt;LOAD CustomerID,&lt;BR /&gt;Customer,&lt;BR /&gt;City,&lt;BR /&gt;Country,&lt;BR /&gt;Region,&lt;BR /&gt;Longitude,&lt;BR /&gt;Latitude,&lt;BR /&gt;Geocoordinates&lt;BR /&gt;FROM&lt;BR /&gt;Customers.txt&lt;BR /&gt;(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);&lt;/P&gt;&lt;P&gt;Employee:&lt;BR /&gt;LOAD EmployeeID,&lt;BR /&gt;Employee,&lt;BR /&gt;Grade,&lt;BR /&gt;SalesUnit&lt;BR /&gt;FROM&lt;BR /&gt;Employees.txt&lt;BR /&gt;(txt, codepage is 1252, embedded labels, delimiter is '\t', msq)&lt;BR /&gt;WHERE MATCH (Grade, 0, 1, 2, 3); //SALES PEOPLE&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;//***** COUNT ID records in each table *****//&lt;BR /&gt;LET vCustCount = FieldValueCount('CustomerID');&lt;BR /&gt;LET vProdCount = FieldValueCount('ProductID');&lt;BR /&gt;LET vEmpCount = FieldValueCount('EmployeeID');&lt;/P&gt;&lt;P&gt;// Create a loop of 10,000 iterations&lt;/P&gt;&lt;P&gt;FOR i = 1 to 10000&lt;/P&gt;&lt;P&gt;// 'A' type of records are for any date /time&lt;/P&gt;&lt;P&gt;// Grab a random employee and customer&lt;BR /&gt;LET vRnd = Floor (Rand () * $(vEmpCount));&lt;BR /&gt;LET vEID = Peek ('EmployeeID', '$(vRnd)', 'Employee');&lt;/P&gt;&lt;P&gt;LET vRnd = Floor (Rand () * $(vCustCount));&lt;BR /&gt;LET vCID = Peek ('CustomerID', '$(vRnd)', 'Customer');&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;//Create a date for any time of day between 9 - 5&lt;BR /&gt;LET vOrderDate = $(vStartDate) + Floor (Rand () * $(vNumDays)) + ((9/ 24) + (Rand () / 3));&lt;/P&gt;&lt;P&gt;//Calculate a random freight amount&lt;BR /&gt;LET vFreight = ROUND(RAND () * 100, 0.01);&lt;/P&gt;&lt;P&gt;//Create the header record&lt;BR /&gt;OrderHeader:&lt;BR /&gt;LOAD&lt;BR /&gt;'A' &amp;amp; $(i) as OrderID,&lt;BR /&gt;$(vOrderDate) as OrderDate,&lt;BR /&gt;$(vCID) as CustomerID,&lt;BR /&gt;$(vEID) as EmployeeID,&lt;BR /&gt;$(vFreight) as Freight&lt;BR /&gt;AutoGenerate (1);&lt;/P&gt;&lt;P&gt;//Genereate Order Lines&lt;BR /&gt;//This factor allows us to generate adiiferent number of lines depending on the day of the week&lt;/P&gt;&lt;P&gt;LET vWeekDay = NUM (WeekDay ($(vOrderDate)));&lt;BR /&gt;LET vDateFactor = Pow(2, $(vWeekDay))*(1-(Year(Now())-Year($(vOrderDate)))*0.05) ;&lt;/P&gt;&lt;P&gt;//Calculate random number of lines&lt;BR /&gt;LET vPCount = Floor(Rand () * $(vDateFactor)) + 1;&lt;/P&gt;&lt;P&gt;FOR L = 1 to $(vPCount)&lt;BR /&gt;//Calculate random values&lt;BR /&gt;LET vQty = Floor (Rand() * (50+ $(vDateFactor))) +1;&lt;BR /&gt;LET vRnd = Floor (Rand() * '$(vProdCount)');&lt;BR /&gt;LET vPID = Peek ('ProductID', '$(vRnd)', 'Product');&lt;BR /&gt;LET vCost = ApplyMap('Product_Cost_Map', '$(vPID)', 1);&lt;BR /&gt;LET vPrice = ApplyMap('Product_Price_Map' ,'$(vPID)', 1);&lt;/P&gt;&lt;P&gt;OrderLine:&lt;BR /&gt;LOAD&lt;BR /&gt;'A' &amp;amp; $(i) as OrderID,&lt;BR /&gt;$(L) as LineNo,&lt;BR /&gt;$(vPID) as ProductID,&lt;BR /&gt;$(vQty) as Quantity,&lt;BR /&gt;$(vPrice) as SalesPrice,&lt;BR /&gt;$(vCost) as SalesCost,&lt;BR /&gt;$(vQty)* $(vPrice) as LineValue,&lt;BR /&gt;$(vQty)* $(vCost) as LineCost&lt;BR /&gt;AutoGenerate (1);&lt;/P&gt;&lt;P&gt;NEXT&lt;BR /&gt;//"B" type records are for summer peak&lt;BR /&gt;// Summer Peak - Generate additional records for summer months to stimulate a peak trading period&lt;/P&gt;&lt;P&gt;LET vY = Year($(vOrderDate));&lt;BR /&gt;LET vM = Floor (Rand()*2)+7;&lt;BR /&gt;LET vD = Day ($(vOrderDate));&lt;BR /&gt;LET vOrderDate = Floor (MakeDate ($(vY), $(vM), $(vD))) + (9/24) + (Rand() /3);&lt;/P&gt;&lt;P&gt;IF Rand() &amp;gt; 0.8 THEN&lt;BR /&gt;// Grab a random employee and customer&lt;BR /&gt;LET vRnd = FLoor (Rand ()* $(vEmpCount));&lt;BR /&gt;LET vEID = Peek ('EmployeeID', $(vRnd), 'Employee');&lt;BR /&gt;LET vRnd = Floor (Rand() *$(vCustCount));&lt;BR /&gt;LET vCID = Peek ('CustomerID', $(vRnd), 'Customer')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//***** END OF SCRIPT *****//&lt;/P&gt;&lt;P&gt;P.S.&lt;/P&gt;&lt;P&gt;This script is from the book Qlikview Advance Data Visualization.&lt;/P&gt;&lt;P&gt;I am running the script with a debugger now - will let you know if I get a solution&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;a&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 14:55:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660521#M594294</guid>
      <dc:creator>AkbarShaikh</dc:creator>
      <dc:date>2019-12-24T14:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Token</title>
      <link>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660525#M594297</link>
      <description>&lt;P&gt;Hi Fong,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found the error: Table name in Peek function was incorrect:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;FOR L = 1 to $(vPCount)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//Calculate random values&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LET vQty = Floor (Rand() * (50+ $(vDateFactor))) +1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LET vRnd = Floor (Rand() * '$(vProdCount)');&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;LET vPID = Peek ('ProductID', '$(vRnd)', 'Product'); // The table name is Products&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;LET vCost = ApplyMap('Product_Cost_Map', '$(vPID)', 1);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LET vPrice = ApplyMap('Product_Price_Map' ,'$(vPID)', 1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script did run without given any 'token' error but has created a Syn key on Product Id and Sales Price.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I rename these two fields, the Product table does not connect to the fact table (Order Header).&lt;/P&gt;&lt;P&gt;I have attached the table view for your reference.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 15:21:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Unexpected-Token/m-p/1660525#M594297</guid>
      <dc:creator>AkbarShaikh</dc:creator>
      <dc:date>2019-12-24T15:21:22Z</dc:date>
    </item>
  </channel>
</rss>

