<?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: Showing only first and last questions/answers in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Showing-only-first-and-last-questions-answers/m-p/1509348#M43973</link>
    <description>&lt;P&gt;Thank you very much for this! I almost have it working for my actual data set, which is a little more complex. The important thing is that I see what you did and understand it. I plan on using this for other projects going forward.&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;Bob&lt;/P&gt;</description>
    <pubDate>Mon, 19 Nov 2018 21:04:22 GMT</pubDate>
    <dc:creator>blpetosa</dc:creator>
    <dc:date>2018-11-19T21:04:22Z</dc:date>
    <item>
      <title>Showing only first and last questions/answers</title>
      <link>https://community.qlik.com/t5/App-Development/Showing-only-first-and-last-questions-answers/m-p/1508245#M43956</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;I am working on a project where I am trying to keep only the first "fail" grade and last "pass" grade for users. I need the output in a Qlik Sense Table visualization. Please refer to the attached document for sample data. This only shows the journey of one user, but there will be many more. Some things to note:&lt;/P&gt;&lt;P&gt;1. There are two&amp;nbsp; test_type's (Pre-1,Post-2). Users can only take the Pre-test once, so I will always keep that regardless of if they pass or fail. The Post-test (type 2) is where I only want the first fail, and final pass(users hardly ever take again after passing, but it is possible). Makes me think I may need an "if(test_type=2,?,?)" logic for this field, and both the date and time fields need to be referenced (min/max/firstsortedvalue???).&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. The desired output for this example would be rows:&lt;/P&gt;&lt;P&gt;2,3,4,5,6,7,14,15,16&lt;/P&gt;&lt;P&gt;Thank you in advance for any help,&lt;/P&gt;&lt;P&gt;Bob&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 07:16:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Showing-only-first-and-last-questions-answers/m-p/1508245#M43956</guid>
      <dc:creator>blpetosa</dc:creator>
      <dc:date>2024-11-16T07:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: Showing only first and last questions/answers</title>
      <link>https://community.qlik.com/t5/App-Development/Showing-only-first-and-last-questions-answers/m-p/1508442#M43971</link>
      <description>&lt;P&gt;&lt;SPAN&gt;The best practice is to prepare this information in your load script, rather than calculate it on-the-fly when you need it. The script below uses your spreadsheet to load a table with the data. It also adds two fields; a test_id that uniquely identifies each test; and a flag called "report" at the end of the record. This flag will be&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;1&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;for each question of each test that fits your criteria, otherwise it will be null.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This gives you a lot more flexibility. You can just display the each question or test_id for a user where the report_flag = 1. You also can reduce your data, keeping only the records where report_flag = 1. I think this option is closer to that you want.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The script is below. If you run it you will see that the records you wanted have report_flag = 1. The ones you don't want have report_flag = null. To reduce the data, simply load the table to another table "where report_flag = 1".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I've also attached a spreadsheet with the contents of the Scores table after you run this script.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I hope this solves your issue.&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;// First load in the spreadsheet.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[RawScores]:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;LOAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[user],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[date],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[time],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[test_type],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[question_order],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[question],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[answer],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[pass_fail]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;FROM [lib://Data/Test Example.xlsx]&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;// Change to be your data file to load&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(ooxml, embedded labels, table is Sheet1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;//Now, loop through the table you loaded and add a unique test_id for each test.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Let vNumRows = NoOfRows('RawScores');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Let vKey = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Set vConcatenate = 'NoConcatenate';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For i = 0 to $(vNumRows)-1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;If Peek('question_order', i, 'RawScores') = 0 then&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;Let vKey = vKey + 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;End If&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Scores:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;$(vConcatenate) LOAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;$(vKey) as test_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;Peek('user', $(i), 'RawScores') as [user],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;Peek('date', $(i), 'RawScores') as [date],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;Peek('time', $(i), 'RawScores') as [time],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;Peek('test_type', $(i), 'RawScores') as [test_type],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;Peek('question_order', $(i), 'RawScores') as [question_order],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;Peek('question', $(i), 'RawScores') as [question],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;Peek('answer', $(i), 'RawScores') as [answer],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;Peek('pass_fail', $(i), 'RawScores') as [pass_fail]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;AutoGenerate 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Set vConcatenate = 'Concatenate';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Next;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Drop Table [RawScores];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;// Identify the pre-test records&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[ScoreStatus]:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Load&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Max(test_id) as test_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Resident [Scores]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Where [test_type] = 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Group by [user];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;// Identify the last test that the user passed.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[ScoreStatus]:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Concatenate Load&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Max(test_id) as test_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Resident [Scores]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Where [pass_fail] = 'pass' and [test_type] = 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Group by [user];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;// Identify the first test that the user failed&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[ScoreStatus]:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Concatenate Load&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Min(test_id) as test_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Resident [Scores]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Where [pass_fail] = 'fail' and [test_type] = 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Group by [user];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;// Now, add the report_flag to table Scores.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Scores:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Left Join (Scores)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Load&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;test_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;1 as report_flag&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Resident [ScoreStatus];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Drop Table [ScoreStatus];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Nov 2018 06:45:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Showing-only-first-and-last-questions-answers/m-p/1508442#M43971</guid>
      <dc:creator>lblumenfeld</dc:creator>
      <dc:date>2018-11-17T06:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: Showing only first and last questions/answers</title>
      <link>https://community.qlik.com/t5/App-Development/Showing-only-first-and-last-questions-answers/m-p/1508444#M43972</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Note: In the code in my previous response, the Qlik editor will flag the code "$(vConcatenate) LOAD" as an error. You can ignore that. It's okay.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Nov 2018 06:29:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Showing-only-first-and-last-questions-answers/m-p/1508444#M43972</guid>
      <dc:creator>lblumenfeld</dc:creator>
      <dc:date>2018-11-17T06:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Showing only first and last questions/answers</title>
      <link>https://community.qlik.com/t5/App-Development/Showing-only-first-and-last-questions-answers/m-p/1509348#M43973</link>
      <description>&lt;P&gt;Thank you very much for this! I almost have it working for my actual data set, which is a little more complex. The important thing is that I see what you did and understand it. I plan on using this for other projects going forward.&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;Bob&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 21:04:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Showing-only-first-and-last-questions-answers/m-p/1509348#M43973</guid>
      <dc:creator>blpetosa</dc:creator>
      <dc:date>2018-11-19T21:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Showing only first and last questions/answers</title>
      <link>https://community.qlik.com/t5/App-Development/Showing-only-first-and-last-questions-answers/m-p/1509356#M43974</link>
      <description>&lt;P&gt;You're very welcome. Post again if you run into any other issues.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 21:23:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Showing-only-first-and-last-questions-answers/m-p/1509356#M43974</guid>
      <dc:creator>lblumenfeld</dc:creator>
      <dc:date>2018-11-19T21:23:01Z</dc:date>
    </item>
  </channel>
</rss>

