<?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 Create a counting table by ID in Connectivity &amp; Data Prep</title>
    <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Create-a-counting-table-by-ID/m-p/2161772#M13239</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm having trouble to build a counting table of a "flag" table.&lt;/P&gt;
&lt;P&gt;This flag table holds about 15 values that might be common between the different fields, eg:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FlagTable:&lt;/P&gt;
&lt;P&gt;LOAD * Inline [email, phone, name, address, birthday&lt;/P&gt;
&lt;P&gt;error, ok, ok, empty, error&lt;/P&gt;
&lt;P&gt;ok, ok, error, empty, error&lt;/P&gt;
&lt;P&gt;ok, ok, ok, empty, ok&lt;/P&gt;
&lt;P&gt;error, ok, empty, ok, ok&lt;/P&gt;
&lt;P&gt;];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've built this table and now I need to put the values as columns and the column names as a dimension:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CountTable:&lt;/P&gt;
&lt;P&gt;LOAD * Inline [field_name, ok, error, empty&lt;/P&gt;
&lt;P&gt;email&lt;/P&gt;
&lt;P&gt;phone&lt;/P&gt;
&lt;P&gt;name&lt;/P&gt;
&lt;P&gt;address&lt;/P&gt;
&lt;P&gt;birthday&lt;/P&gt;
&lt;P&gt;];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I can end up with a table holding the count for each new column (ok, error, empty):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;field_name | ok | error | empty&lt;/P&gt;
&lt;P&gt;email | 2 | 2 | 0&lt;/P&gt;
&lt;P&gt;phone | 4 | 0 | 0&lt;/P&gt;
&lt;P&gt;name | 2 | 1 |&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;address | 1 | 0 | 3&amp;nbsp;&lt;/P&gt;
&lt;P&gt;birthday | 2 | 2 | 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I tried to do is to conditionally count the values and group them by field_name. For that I've built a loop based on CountTable rows and peeked each field_name, to concatenate the rows and built the complete table (not sure if it's possible without a loop).&lt;/P&gt;
&lt;P&gt;LET vFieldName = Peek('field_name',&amp;nbsp; $(i), 'CountTable')&lt;/P&gt;
&lt;P&gt;Temp_Count:&lt;/P&gt;
&lt;P&gt;NoConcatenate LOAD&lt;BR /&gt;&lt;BR /&gt;'$(vFieldName)' as field_name&lt;/P&gt;
&lt;P&gt;,Count(If($(field_name) = 'ok', $(vFieldName))) as ok&lt;/P&gt;
&lt;P&gt;,Count(If($(field_name) = 'error', $(vFieldName))) as error&lt;/P&gt;
&lt;P&gt;,Count(If($(field_name) = 'empty', $(vFieldName))) as empty&lt;/P&gt;
&lt;P&gt;Resident FlagTable&lt;BR /&gt;Group By $(vFieldName);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to make it simpler, didn't add the loop, etc, but I think you can see where I'm trying to get. The problem with this final table is that it doesn't group by the dimension, but gives me 1 row for each value instead (ok, error, empty in this case). So after concatenating the different field_name, I have 15 rows instead of 5.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could anyone help me out?&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jan 2024 01:43:38 GMT</pubDate>
    <dc:creator>pedrohenriqueperna</dc:creator>
    <dc:date>2024-01-16T01:43:38Z</dc:date>
    <item>
      <title>Create a counting table by ID</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Create-a-counting-table-by-ID/m-p/2161772#M13239</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm having trouble to build a counting table of a "flag" table.&lt;/P&gt;
&lt;P&gt;This flag table holds about 15 values that might be common between the different fields, eg:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FlagTable:&lt;/P&gt;
&lt;P&gt;LOAD * Inline [email, phone, name, address, birthday&lt;/P&gt;
&lt;P&gt;error, ok, ok, empty, error&lt;/P&gt;
&lt;P&gt;ok, ok, error, empty, error&lt;/P&gt;
&lt;P&gt;ok, ok, ok, empty, ok&lt;/P&gt;
&lt;P&gt;error, ok, empty, ok, ok&lt;/P&gt;
&lt;P&gt;];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've built this table and now I need to put the values as columns and the column names as a dimension:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CountTable:&lt;/P&gt;
&lt;P&gt;LOAD * Inline [field_name, ok, error, empty&lt;/P&gt;
&lt;P&gt;email&lt;/P&gt;
&lt;P&gt;phone&lt;/P&gt;
&lt;P&gt;name&lt;/P&gt;
&lt;P&gt;address&lt;/P&gt;
&lt;P&gt;birthday&lt;/P&gt;
&lt;P&gt;];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I can end up with a table holding the count for each new column (ok, error, empty):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;field_name | ok | error | empty&lt;/P&gt;
&lt;P&gt;email | 2 | 2 | 0&lt;/P&gt;
&lt;P&gt;phone | 4 | 0 | 0&lt;/P&gt;
&lt;P&gt;name | 2 | 1 |&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;address | 1 | 0 | 3&amp;nbsp;&lt;/P&gt;
&lt;P&gt;birthday | 2 | 2 | 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I tried to do is to conditionally count the values and group them by field_name. For that I've built a loop based on CountTable rows and peeked each field_name, to concatenate the rows and built the complete table (not sure if it's possible without a loop).&lt;/P&gt;
&lt;P&gt;LET vFieldName = Peek('field_name',&amp;nbsp; $(i), 'CountTable')&lt;/P&gt;
&lt;P&gt;Temp_Count:&lt;/P&gt;
&lt;P&gt;NoConcatenate LOAD&lt;BR /&gt;&lt;BR /&gt;'$(vFieldName)' as field_name&lt;/P&gt;
&lt;P&gt;,Count(If($(field_name) = 'ok', $(vFieldName))) as ok&lt;/P&gt;
&lt;P&gt;,Count(If($(field_name) = 'error', $(vFieldName))) as error&lt;/P&gt;
&lt;P&gt;,Count(If($(field_name) = 'empty', $(vFieldName))) as empty&lt;/P&gt;
&lt;P&gt;Resident FlagTable&lt;BR /&gt;Group By $(vFieldName);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to make it simpler, didn't add the loop, etc, but I think you can see where I'm trying to get. The problem with this final table is that it doesn't group by the dimension, but gives me 1 row for each value instead (ok, error, empty in this case). So after concatenating the different field_name, I have 15 rows instead of 5.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could anyone help me out?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 01:43:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Create-a-counting-table-by-ID/m-p/2161772#M13239</guid>
      <dc:creator>pedrohenriqueperna</dc:creator>
      <dc:date>2024-01-16T01:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create a counting table by ID</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Create-a-counting-table-by-ID/m-p/2161788#M13240</link>
      <description>&lt;P&gt;hi&lt;/P&gt;
&lt;P&gt;Try like below&lt;/P&gt;
&lt;DIV&gt;Test:&lt;/DIV&gt;
&lt;DIV&gt;CrossTable(Key, State)&lt;/DIV&gt;
&lt;DIV&gt;LOAD RowNo() as SNO, * Inline [email, phone, name, address, birthday&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;error, ok, ok, empty, error&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;ok, ok, error, empty, error&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;ok, ok, ok, empty, ok&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;error, ok, empty, ok, ok&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;];&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Left Join (Test)&lt;/DIV&gt;
&lt;DIV&gt;LOAD Key,&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; State,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Count(State) as Count&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;Resident Test&lt;/DIV&gt;
&lt;DIV&gt;Group By Key, State;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;FinalTable:&lt;/DIV&gt;
&lt;DIV&gt;LOAD DISTINCT Key&lt;/DIV&gt;
&lt;DIV&gt;Resident Test;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;FOR i = 1 to FieldValueCount('State')&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; LET vState = FieldValue('State', $(i));&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Left Join (FinalTable)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; LOAD DISTINCT Key,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Count as [$(vState)]&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Resident Test&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Where State = '$(vState)';&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;NEXT&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;DROP Table Test;&lt;/DIV&gt;</description>
      <pubDate>Tue, 16 Jan 2024 03:19:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Create-a-counting-table-by-ID/m-p/2161788#M13240</guid>
      <dc:creator>MayilVahanan</dc:creator>
      <dc:date>2024-01-16T03:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create a counting table by ID</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Create-a-counting-table-by-ID/m-p/2162003#M13242</link>
      <description>&lt;P&gt;Hi, &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/17935"&gt;@MayilVahanan&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much!! It worked perfectly adapting as the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Test:&lt;BR /&gt;CrossTable(Key, State)&lt;BR /&gt;LOAD RowNo() as SNO,&lt;BR /&gt;espelho_email, &lt;BR /&gt;espelho_nome, &lt;BR /&gt;espelho_rua, &lt;BR /&gt;espelho_bairro, &lt;BR /&gt;espelho_cidade, &lt;BR /&gt;espelho_complemento, &lt;BR /&gt;espelho_telefone, &lt;BR /&gt;espelho_celular, &lt;BR /&gt;espelho_nascimento&lt;BR /&gt;From [$(vTDS)/Cliente_Espelho.qvd] (qvd);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Left Join (Test)&lt;BR /&gt;LOAD Key,&lt;BR /&gt;State,&lt;BR /&gt;Count(State) as Count&lt;BR /&gt;Resident Test&lt;BR /&gt;Group By Key, State;&lt;BR /&gt;&lt;BR /&gt;FinalTable:&lt;BR /&gt;LOAD DISTINCT Key&lt;BR /&gt;Resident Test;&lt;BR /&gt;&lt;BR /&gt;FOR i = 1 to FieldValueCount('State')&lt;BR /&gt;&lt;BR /&gt;LET vState = FieldValue('State', $(i));&lt;BR /&gt;&lt;BR /&gt;Left Join (FinalTable)&lt;BR /&gt;LOAD DISTINCT Key,&lt;BR /&gt;Count as [$(vState)]&lt;BR /&gt;Resident Test&lt;BR /&gt;Where State = '$(vState)';&lt;BR /&gt;&lt;BR /&gt;NEXT&lt;BR /&gt;&lt;BR /&gt;DROP Table Test;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm now curious to understand the approach. I understand Crosstable will do the job of transposing the field values to columns, but what is RowNo doing and "SNO" as a new field? (specially SNO, because it seems to not be used further in the script).&lt;/P&gt;
&lt;P&gt;I also got a bit confused on what happened in the first count table you joined to "Test" table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you explain me better, just for the sake of knowledge?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 13:19:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Create-a-counting-table-by-ID/m-p/2162003#M13242</guid>
      <dc:creator>pedrohenriqueperna</dc:creator>
      <dc:date>2024-01-16T13:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create a counting table by ID</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Create-a-counting-table-by-ID/m-p/2162078#M13243</link>
      <description>&lt;P&gt;One more doubt:&lt;/P&gt;
&lt;P&gt;If I had to consider a date field that exists within the flag table before we transposed the fields, but in this case I wouldn't transpose the date field, but use it as a dimension to group the counting. How would it be done?&lt;/P&gt;
&lt;P&gt;Instead of a single row for each Key, I'd have 5 Keys for each date present in the table, e.g:&lt;/P&gt;
&lt;P&gt;date_field | field_name | ok | error | empty&lt;/P&gt;
&lt;P&gt;01/01/24 | email | 2 | 2 | 0&lt;/P&gt;
&lt;P&gt;01/01/24 | phone | 4 | 0 | 0&lt;/P&gt;
&lt;P&gt;01/01/24 | name | 2 | 1 | 1&lt;/P&gt;
&lt;P&gt;01/01/24 | address | 1 | 0 | 3&lt;/P&gt;
&lt;P&gt;01/01/24 | birthday | 2 | 2 | 0&lt;/P&gt;
&lt;P&gt;02/01/24 | email | 12 | 8 | 3&lt;/P&gt;
&lt;P&gt;02/01/24 | phone | 74 | 8 | 5&lt;/P&gt;
&lt;P&gt;02/01/24 | name | 22 | 11 | 19&lt;/P&gt;
&lt;P&gt;02/01/24 | address | 1 | 10 | 32&lt;/P&gt;
&lt;P&gt;02/01/24 | birthday | 24 | 29 | 30&lt;/P&gt;
&lt;P&gt;etc...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 15:35:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Create-a-counting-table-by-ID/m-p/2162078#M13243</guid>
      <dc:creator>pedrohenriqueperna</dc:creator>
      <dc:date>2024-01-16T15:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create a counting table by ID</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Create-a-counting-table-by-ID/m-p/2162139#M13244</link>
      <description>&lt;P&gt;Regarding adding an extra date field as a dimension, I removed the RowNo as qualification field and added date_field. Then loaded DISTINCT 'Key' but also 'date_field' and it worked.&lt;/P&gt;
&lt;P&gt;I suppose RowNo had the purpose of being a qualification field, as it will generate "ids" for each line. Considering date_field is also an "id" it worked when substituting.&lt;/P&gt;
&lt;P&gt;Thank you very much again, I probably wouldn't have done it by myself or it'd have taken me too long.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 19:22:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Create-a-counting-table-by-ID/m-p/2162139#M13244</guid>
      <dc:creator>pedrohenriqueperna</dc:creator>
      <dc:date>2024-01-16T19:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create a counting table by ID</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Create-a-counting-table-by-ID/m-p/2162278#M13245</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;Yes, you are right. if you have Date field , you can use as Id column. If there is no field, but need to transpose all the field, then Rowno() act as the "ID" field.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 07:49:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Create-a-counting-table-by-ID/m-p/2162278#M13245</guid>
      <dc:creator>MayilVahanan</dc:creator>
      <dc:date>2024-01-17T07:49:10Z</dc:date>
    </item>
  </channel>
</rss>

