<?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: Incrementing a measure using data from a dimension in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Incrementing-a-measure-using-data-from-a-dimension/m-p/2331039#M100063</link>
    <description>&lt;P&gt;Is Var.nbr a variable in a tMap?&amp;nbsp; It is possible it is resetting because the lifespan of that variable is only for one row.&amp;nbsp; Try using a variable in the globalMap.&amp;nbsp; Can you show a screenshot of your tMap map editor?&lt;/P&gt;</description>
    <pubDate>Tue, 28 May 2019 08:14:30 GMT</pubDate>
    <dc:creator>nfz11</dc:creator>
    <dc:date>2019-05-28T08:14:30Z</dc:date>
    <item>
      <title>Incrementing a measure using data from a dimension</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Incrementing-a-measure-using-data-from-a-dimension/m-p/2331038#M100062</link>
      <description>&lt;P&gt;So I'm trying to create a fact table with a certain measure. I have two dimensions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Stagiaire(id_stagiaire;nom;prenom;departement;id_projet)&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;PRE&gt;Pointage(id_pointage;id_stagiaire;date)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With the second being my relationship table (it's a one to many relationship).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the fact table I want to add a measure called number_of_delays which is calculated using the date column in Pointage. The idea is this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I compare the date of each row with a given format, in my case this:&lt;/P&gt;
&lt;PRE&gt;TalendDate.compareDate(row3.date,TalendDate.parseDate("HH:mm", "09:00"),"HH:mm")&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then according to the result (it return either -1,0 or 1 and I'm testing with 1) I increment a global variable using a local variable (Var.nbr). This is what I made so far:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The value of the measure is calculated using&lt;/P&gt;
&lt;PRE&gt;TalendDate.compareDate(
	row3.date,
	TalendDate.parseDate("HH:mm", "09:00"),
	"HH:mm") == 1 ? (
		Numeric.sequence("Var.nbr",1,1)
	):(int)globalMap.get("Stagiaire"+row3.id_stagiaire) &lt;/PRE&gt;
&lt;P&gt;This partially works. Instead of incrementing the number of delays for each Stagiaire id, it just keeps incrementing the same variable and putting in the database.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I achieve this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TL;DR I need to increment the value of a measure according to an id using a test, so if the test of user 1 was passed 2 out of 3 times, the value would be 2, and if the test of user 2 passed 5 times out of 9, the value will be 5 and so on.&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 20:30:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Incrementing-a-measure-using-data-from-a-dimension/m-p/2331038#M100062</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-23T20:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Incrementing a measure using data from a dimension</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Incrementing-a-measure-using-data-from-a-dimension/m-p/2331039#M100063</link>
      <description>&lt;P&gt;Is Var.nbr a variable in a tMap?&amp;nbsp; It is possible it is resetting because the lifespan of that variable is only for one row.&amp;nbsp; Try using a variable in the globalMap.&amp;nbsp; Can you show a screenshot of your tMap map editor?&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 08:14:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Incrementing-a-measure-using-data-from-a-dimension/m-p/2331039#M100063</guid>
      <dc:creator>nfz11</dc:creator>
      <dc:date>2019-05-28T08:14:30Z</dc:date>
    </item>
  </channel>
</rss>

