<?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: Create Field and value in Script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Create-Field-and-value-in-Script/m-p/1741047#M590847</link>
    <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22593"&gt;@rubenmarin&lt;/a&gt;&amp;nbsp; Hey Ruben, apologies for the notification issues we have been having, just wanted to flag this one for you.&lt;/P&gt;&lt;P&gt;Cheers,&lt;BR /&gt;Brett&lt;/P&gt;</description>
    <pubDate>Thu, 03 Sep 2020 15:36:41 GMT</pubDate>
    <dc:creator>Brett_Bleess</dc:creator>
    <dc:date>2020-09-03T15:36:41Z</dc:date>
    <item>
      <title>Create Field and value in Script</title>
      <link>https://community.qlik.com/t5/QlikView/Create-Field-and-value-in-Script/m-p/1737933#M590844</link>
      <description>&lt;P&gt;I need to create a new dimension based on this logic below. One workstation can have many test cases with different statuses. How do I replace the set analysis correctly to be used in the script?&lt;/P&gt;&lt;P&gt;For each workstation&lt;BR /&gt;If all testcase status = null then workstation status = not tested&lt;BR /&gt;else&lt;BR /&gt;If any testcase status = failed then workstation status = failed&lt;BR /&gt;Else if any testcase status = null then workstation status = incomplete&lt;BR /&gt;Else if any testcase status = ready for retest then workstation status = ready for retests&lt;BR /&gt;Else (all test case status = passed) then workstation status = passed&lt;/P&gt;&lt;P&gt;~~~~~~~~~~~~~~~~&lt;/P&gt;&lt;P&gt;LOAD Department,&lt;BR /&gt;Workstation,&lt;BR /&gt;[Test Case],&lt;BR /&gt;Workstation &amp;amp; '-' &amp;amp; [Test Case] as %KeyWorkstation_TC,&lt;BR /&gt;if(isnull( Status),'Not Tested', Status) as Status,&lt;BR /&gt;&lt;BR /&gt;if(not match(Status,'Failed','Passed','Ready to Retest'),'Not Tested',&lt;BR /&gt;if(not match(Status,'Failed','Ready to Retest','Incomplete'),'Passed',&lt;BR /&gt;if(count({&amp;lt;Status*={"Failed"}&amp;gt;} distinct Workstation)&amp;gt;=1,'Failed',&lt;BR /&gt;if (count({&amp;lt;Status={"Not Tested"}&amp;gt;} distinct Workstation)&amp;gt;=1,'Incomplete',&lt;BR /&gt;if(count({&amp;lt;Status*={"Ready to Retest"}&amp;gt;} distinct Workstation)&amp;gt;=1,'Ready to Retest','Other'&lt;BR /&gt;))))), as WORKSTATION_STATUS,&lt;/P&gt;&lt;P&gt;Timestamp,&lt;BR /&gt;User,&lt;BR /&gt;&lt;BR /&gt;[Failure Reason],&lt;BR /&gt;//[Mapped Printer],&lt;BR /&gt;Comments&lt;BR /&gt;FROM&lt;BR /&gt;[..\External_Data\TDR 8-19 Test Results EPIC.xlsx]&lt;BR /&gt;(ooxml, embedded labels, table is Sheet1);&lt;/P&gt;</description>
      <pubDate>Sat, 22 Aug 2020 15:56:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-Field-and-value-in-Script/m-p/1737933#M590844</guid>
      <dc:creator>cbaqir</dc:creator>
      <dc:date>2020-08-22T15:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create Field and value in Script</title>
      <link>https://community.qlik.com/t5/QlikView/Create-Field-and-value-in-Script/m-p/1737948#M590845</link>
      <description>&lt;P&gt;Hi, you can't use set analysis in script. Also to use aggregation functions like Count() you need a Group By.&lt;/P&gt;&lt;P&gt;I will try to assign the workstation status in next steps, as an example:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// mapping to assign a code to each status (null will be zero)
mapStatus:
Mapping LOAd * Inline [
Status, Code
Failed, 1
Ready to Retest,2
Passed, 3
]

// Load data and assign number to status
Data:
LOAD Department,
  ...,
  Applymap('mapStatus', Status, 0) as codStatus
FROM ...;

// Identify 'Not Tested'
chkNotTested:
LOAD Workstation as chkNotTested
Where MaxValue=0;
LOAD Workstation,
  Max(codStatus) as MaxValue
Resident Data
Group By Workstation;

// Set status to each workstation
// This table can be joined with Data table or leave it as independent table
WorkstationStatus:
LOAD Workstation
  If(Exists('chkNotTested', Workstation), 'Not Tested'
    ,If(MinValue=0, 'Incomplete'
      ,If(MinValue=1, 'Failed'
        ,If(MinValue=2, 'Ready for Retest'
          ,If(MinValue=3, 'Passed', 'Other (recheck logic)'
  ))))) as WorkstationStatus;
LOAD Workstation
  Min(codStatus) as MinValue
Resident Data
Group By Workstation;

DROP Table chkNotTested;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;The code is not testedm maybe there is a typo or something to fix but that's the idea.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Aug 2020 09:13:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-Field-and-value-in-Script/m-p/1737948#M590845</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2020-08-23T09:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create Field and value in Script</title>
      <link>https://community.qlik.com/t5/QlikView/Create-Field-and-value-in-Script/m-p/1738187#M590846</link>
      <description>&lt;P&gt;Thanks. This is great but I am seeing a discrepancy when I look at one I see as Failed and this logic says incomplete. Failed should have a higher precedence. Any thoughts?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-08-24_7-26-41.jpg" style="width: 497px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/39487i440156191B1CF2CE/image-size/large?v=v2&amp;amp;px=999" role="button" title="2020-08-24_7-26-41.jpg" alt="2020-08-24_7-26-41.jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-08-24_7-27-33.jpg" style="width: 555px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/39488i4F377A9A3AC3CB8E/image-size/large?v=v2&amp;amp;px=999" role="button" title="2020-08-24_7-27-33.jpg" alt="2020-08-24_7-27-33.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 14:28:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-Field-and-value-in-Script/m-p/1738187#M590846</guid>
      <dc:creator>cbaqir</dc:creator>
      <dc:date>2020-08-24T14:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create Field and value in Script</title>
      <link>https://community.qlik.com/t5/QlikView/Create-Field-and-value-in-Script/m-p/1741047#M590847</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22593"&gt;@rubenmarin&lt;/a&gt;&amp;nbsp; Hey Ruben, apologies for the notification issues we have been having, just wanted to flag this one for you.&lt;/P&gt;&lt;P&gt;Cheers,&lt;BR /&gt;Brett&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 15:36:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-Field-and-value-in-Script/m-p/1741047#M590847</guid>
      <dc:creator>Brett_Bleess</dc:creator>
      <dc:date>2020-09-03T15:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create Field and value in Script</title>
      <link>https://community.qlik.com/t5/QlikView/Create-Field-and-value-in-Script/m-p/1741099#M590848</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/14114"&gt;@Brett_Bleess&lt;/a&gt;, thanks for the advise, I wasn't aware. Another Issue I'm finding a lot is that an answers returns an error when posting, and the full post is lost, no option to retrieve. this is the 2nd time I'm answering this post.&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/44206"&gt;@cbaqir&lt;/a&gt;, a possible fix:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;WorkstationStatus:
LOAD Workstation
  If(Exists('chkNotTested', Workstation), 'Not Tested'
    ,If(hasFailed, 'Failed'
      ,If(MinValue=0, 'Incomplete'
        ,If(MinValue=2, 'Ready for Retest'
          ,If(MinValue=3, 'Passed', 'Other (recheck logic)'
  ))))) as WorkstationStatus;
LOAD Workstation
  Min(codStatus) as MinValue,
  If(Index(Concat(codStatus), '1')&amp;gt;0, 1, 0) as hasFailed
Resident Data
Group By Workstation;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 19:17:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-Field-and-value-in-Script/m-p/1741099#M590848</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2020-09-03T19:17:56Z</dc:date>
    </item>
  </channel>
</rss>

