<?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: [resolved] Counters based on data in tMap in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293496#M66465</link>
    <description>Hello 
&lt;BR /&gt;First, your expression of var is not correct, you only put a value to a globalMap key, but don't get it. The if-then-else statement looks like: 
&lt;BR /&gt;condition?value1:value2 
&lt;BR /&gt;if the condition is ture, then var=value1 else var=value2 
&lt;BR /&gt;Here I create a new routine(Go to repository-&amp;gt;code and right click on routines to create a new routine) to fix your need, 
&lt;BR /&gt; 
&lt;PRE&gt;package routines;&lt;BR /&gt;public class forum7741 {&lt;BR /&gt;	static java.util.Map&amp;lt;String, Integer&amp;gt; map = new java.util.HashMap&amp;lt;String, Integer&amp;gt;();&lt;BR /&gt;	public static int getCount(String RCRName) {&lt;BR /&gt;		int count = 0;&lt;BR /&gt;		if (map.get(RCRName) == null) {&lt;BR /&gt;			map.put(RCRName, 1);&lt;BR /&gt;			count = 1;&lt;BR /&gt;		} else {&lt;BR /&gt;			count = map.get(RCRName) + 1;&lt;BR /&gt;			map.put(RCRName, count);&lt;BR /&gt;		}&lt;BR /&gt;		return count;&lt;BR /&gt;	}&lt;BR /&gt;}&lt;/PRE&gt; 
&lt;BR /&gt;So, you need delete you var, then call this routine on expression filed of column, see my screenshot. 
&lt;BR /&gt;Best regards 
&lt;BR /&gt; 
&lt;BR /&gt; shong</description>
    <pubDate>Wed, 12 Aug 2009 06:34:12 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-08-12T06:34:12Z</dc:date>
    <item>
      <title>[resolved] Counters based on data in tMap</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293488#M66457</link>
      <description>Warning: I am fairly new to Talend and have mostly used tMap to import data. I'm running TOS 3.0.3 on Windows in java with FileDelimited and MSSQL input and MSSQL output. I need some help in handling an aspect of the import: 
&lt;BR /&gt;I have a .csv file with records that have different user IDs. I have a MSSQL data table of requests where I look up the user ID to get other data about the request. I'm using a tMap to transform the data and store it in multiple tables, which is working well. I also have to update the request in the MSSQL Lookup table with the number of records read for that user ID. That's where my problem is. 
&lt;BR /&gt;I can see where I could use a variable to count (numeric.sequence?) but that would be an overall count and not specific to a user id. When I try to update the data table as I go along (store updated count per user ID in that request record) hoping to get the new value to increment for each record (expression is "RCRMapping.NumReceived == null ? 1 : RCRMapping.NumReceived + 1" without the quotes of course), it doesn't seem to be doing the writes between csv records to update RCRMapping.NumReceived and I end up always with a value of 1. 
&lt;BR /&gt;Is there a way to force the writes for each read? Is there a better way to keep counts per user id? 
&lt;BR /&gt;I'm attaching a screen shot of a simplified version of my job design and my tMap (there's more to it I deleted just to play with this feature). Please let me know if this isn't clear. 
&lt;BR /&gt;Thanks for the help. 
&lt;BR /&gt;-Deb</description>
      <pubDate>Sat, 16 Nov 2024 13:49:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293488#M66457</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T13:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Counters based on data in tMap</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293489#M66458</link>
      <description>Hello, 
&lt;BR /&gt; There something wrong in your design : you use the RCMMapingTable as Lookup and output in the same subjob 
&lt;BR /&gt; 1) The data from lookup are first loaded, the data are loaded once. So tMap use a copy of data in memory or on disk. 
&lt;BR /&gt; 2) When you update the output RCMMapingTable, the tMap didn't see the new data. 
&lt;BR /&gt; RCRMapping.NumReceived have always the same value ! 
&lt;BR /&gt; You can create in tMap a variable ( between input and output ) and set a globalMap variable by ID to store your data. 
&lt;BR /&gt; Variable= 
&lt;BR /&gt; (Integer)globalMap.get( ID ) ==null? 
&lt;BR /&gt; RCRMapping.NumReceived == null ? globalMap.put(ID, 1) : globalMap.put(ID, RCRMapping.NumReceived +1 ) : globalMap.put(ID, (Integer)globalMap.get( ID ) +1 )</description>
      <pubDate>Tue, 11 Aug 2009 16:45:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293489#M66458</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-11T16:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Counters based on data in tMap</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293490#M66459</link>
      <description>Thanks so much for your help! This is really close. I didn't know about using globalMap. 
&lt;BR /&gt;I tried several contortions of the variable expression, and I keep getting "null, 1, 2" instead of "1, 2, 3" as the values of the variable for the 3 input records. Tried these two expressions most recently, both with the same results: 
&lt;BR /&gt;(Integer)globalMap.get( RCRMapping.RCRName) ==null? RCRMapping.NumReceived == null ? globalMap.put(RCRMapping.RCRName, 1) : globalMap.put(RCRMapping.RCRName, RCRMapping.NumReceived +1 ) : globalMap.put(RCRMapping. RCRName, (Integer)globalMap.get(RCRMapping.RCRName) +1 ) 
&lt;BR /&gt;(Integer)globalMap.get( RCRMapping.RCRName) ==null? globalMap.put(RCRMapping. RCRName, 1) : globalMap.put(RCRMapping. RCRName, (Integer)globalMap.get(RCRMapping. RCRName) +1 ) 
&lt;BR /&gt;Any suggestions? 
&lt;BR /&gt;Also, can you use more than one globalMap (using different fields and mapping to different variables)? 
&lt;BR /&gt;Thanks again for the help! 
&lt;BR /&gt;-Deb</description>
      <pubDate>Tue, 11 Aug 2009 18:58:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293490#M66459</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-11T18:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Counters based on data in tMap</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293491#M66460</link>
      <description>I realize after reading some about globalMap that my question about multiple globalMaps was dumb - I think that if you can have unique values in the "key" (first parameter) then you can store values for multiple variables. Do you know where there is a good writeup explaining globalMap? 
&lt;BR /&gt;I also saw that there were spaces in my expression, but it still isn't working right. I am still getting the first value as NULL and I need it to be 0 or 1 (it does increment correctly after that). Attached is a shot of my tMap with the expression in the variable as follows: 
&lt;BR /&gt;(Integer)globalMap.get( RCRMapping.RCRName) == null ? globalMap.put(RCRMapping.RCRName, 1) : globalMap.put(RCRMapping.RCRName, (Integer)globalMap.get(RCRMapping.RCRName) +1 ) 
&lt;BR /&gt;Any help would be appreciated. 
&lt;BR /&gt;-Deb</description>
      <pubDate>Tue, 11 Aug 2009 23:41:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293491#M66460</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-11T23:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Counters based on data in tMap</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293492#M66461</link>
      <description>Hello guy
&lt;BR /&gt;You can use the the method: Numeric.sequence("s1",1,1), s1 is the sequence name, the first 1 is the start index, the second 1 is the step. it will count all the rows.
&lt;BR /&gt;
&lt;BR /&gt;Best regards
&lt;BR /&gt; shong</description>
      <pubDate>Wed, 12 Aug 2009 03:12:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293492#M66461</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-12T03:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Counters based on data in tMap</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293493#M66462</link>
      <description>Hi Shong, 
&lt;BR /&gt;Thanks for the reply. I did try that, but my issue is I need a separate counter for each user ID, and the .csv records will be interspersed with multiple records for each user ID. Is there a way to use numeric.sequence specific to a piece of data in the lookup table? 
&lt;BR /&gt;Thanks again. 
&lt;BR /&gt;-Deb</description>
      <pubDate>Wed, 12 Aug 2009 03:23:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293493#M66462</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-12T03:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Counters based on data in tMap</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293494#M66463</link>
      <description>Hello Deb
&lt;BR /&gt;Sorry, I don't understand your request. Can you try to give us an example to explain it?
&lt;BR /&gt;Best regards
&lt;BR /&gt; shong</description>
      <pubDate>Wed, 12 Aug 2009 03:32:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293494#M66463</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-12T03:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Counters based on data in tMap</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293495#M66464</link>
      <description>I'll try. The screen shots of a representative job and tMap are in the first post. 
&lt;BR /&gt;This is the crux of the issue: I have a table that lists participants to request data from, and I'm getting data in from a .csv with multiple records (customers) per participant that contains the requested data. Example data might be: 
&lt;BR /&gt;RequestTable (Lookup Table before load) 
&lt;BR /&gt; ParticipantName ParticipantID DateReceived NumReceived 
&lt;BR /&gt; JoeSmith 111 
&lt;BR /&gt; SueDoe 222 
&lt;BR /&gt;Contents of tFileInputDelimited might be like: 
&lt;BR /&gt; ParticipantName CustomerID Answer 1 Answer 2 
&lt;BR /&gt; JoeSmith 12 yes no 
&lt;BR /&gt; JoeSmith 13 no no 
&lt;BR /&gt; JoeSmith 14 no no 
&lt;BR /&gt; SueDoe 21 yes yes 
&lt;BR /&gt; SueDoe 22 no yes 
&lt;BR /&gt;The Lookup Table is to convert participantName to ParticipantID for other reasons, but in the end, I want the RequestTable updated to reflect what was read, specifically the NumReceived (count of records for that ParticipantName) like: 
&lt;BR /&gt; ParticipantName ParticipantID DateReceived NumReceived 
&lt;BR /&gt; JoeSmith 111 8/11/09 3 
&lt;BR /&gt; SueDoe 222 8/11/09 2 
&lt;BR /&gt;And I need a data table updated that has the ordinal number of that Customer ID within the participant list (I assumed I could get the ordinal number from the "current" NumReceived for that Participant as I went along): 
&lt;BR /&gt; ParticipantID ParticipantName CustomerID CustomerNumber 
&lt;BR /&gt; JoeSmith 111 12 1 
&lt;BR /&gt; JoeSmith 111 13 2 
&lt;BR /&gt; JoeSmith 111 14 3 
&lt;BR /&gt; SueDoe 222 21 1 
&lt;BR /&gt; SueDoe 222 22 2 
&lt;BR /&gt;I know there are other ways to do this, like load it raw into a database and count it there, but I was trying to do the counts as I process the input file in the tMap where I already update several other data tables, which is the part that's working fine (I tried adding the counts recently to a working job). 
&lt;BR /&gt;Emenuet suggested a globalMap, which definitely helped and got me closer, but I don't think my syntax was right. I could use help in setting the variable expression to get the counts in a globalMap, and the expressions for NumReceived and CustomerNumber using the variable. 
&lt;BR /&gt;Let me know if this still doesn't make sense. Thanks for the help. 
&lt;BR /&gt;-Deb</description>
      <pubDate>Wed, 12 Aug 2009 04:37:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293495#M66464</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-12T04:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Counters based on data in tMap</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293496#M66465</link>
      <description>Hello 
&lt;BR /&gt;First, your expression of var is not correct, you only put a value to a globalMap key, but don't get it. The if-then-else statement looks like: 
&lt;BR /&gt;condition?value1:value2 
&lt;BR /&gt;if the condition is ture, then var=value1 else var=value2 
&lt;BR /&gt;Here I create a new routine(Go to repository-&amp;gt;code and right click on routines to create a new routine) to fix your need, 
&lt;BR /&gt; 
&lt;PRE&gt;package routines;&lt;BR /&gt;public class forum7741 {&lt;BR /&gt;	static java.util.Map&amp;lt;String, Integer&amp;gt; map = new java.util.HashMap&amp;lt;String, Integer&amp;gt;();&lt;BR /&gt;	public static int getCount(String RCRName) {&lt;BR /&gt;		int count = 0;&lt;BR /&gt;		if (map.get(RCRName) == null) {&lt;BR /&gt;			map.put(RCRName, 1);&lt;BR /&gt;			count = 1;&lt;BR /&gt;		} else {&lt;BR /&gt;			count = map.get(RCRName) + 1;&lt;BR /&gt;			map.put(RCRName, count);&lt;BR /&gt;		}&lt;BR /&gt;		return count;&lt;BR /&gt;	}&lt;BR /&gt;}&lt;/PRE&gt; 
&lt;BR /&gt;So, you need delete you var, then call this routine on expression filed of column, see my screenshot. 
&lt;BR /&gt;Best regards 
&lt;BR /&gt; 
&lt;BR /&gt; shong</description>
      <pubDate>Wed, 12 Aug 2009 06:34:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293496#M66465</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-12T06:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Counters based on data in tMap</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293497#M66466</link>
      <description>Got it working!! Thanks so much to both emenuet and Shong. I had to do a combination of the two answers. 
&lt;BR /&gt;I added the routine as Shong wrote (worked perfectly), but since I needed to use the value in multiple tables, I had to make the call to the routine in a variable, and use the variable in multiple places. Otherwise it incremented the counter every time I called it. 
&lt;BR /&gt;So I changed "forum7741" to "PatientCount" in Shong's example and my variable expression is: 
&lt;BR /&gt;routines.PatientCount.getCount(RCRMapping.RCRName) 
&lt;BR /&gt;declared as Type int, Var name thisPatient 
&lt;BR /&gt;and my expression in the tables (reference to the count) is: 
&lt;BR /&gt;Var.thisPatient 
&lt;BR /&gt;Hope this helps others who want to do the same thing. 
&lt;BR /&gt;I am very impressed with the responsiveness and quality of the answers in this forum. Great work! 
&lt;BR /&gt;Regards, 
&lt;BR /&gt;-Deb</description>
      <pubDate>Wed, 12 Aug 2009 16:04:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Counters-based-on-data-in-tMap/m-p/2293497#M66466</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-12T16:04:10Z</dc:date>
    </item>
  </channel>
</rss>

