<?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: Min/Max Attempt in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Min-Max-Attempt/m-p/1531587#M38277</link>
    <description>&lt;P&gt;Please try this:&lt;/P&gt;&lt;PRE&gt;Quiz:
LOAD quiz_id,
quiz_name,
quiz_date,
segment_id,
user_id,
site_id as quiz_site,
test_type,
question,
question_order,
answer_order as order,
answer_or_sub_question,
question_id,
solution_id,
solution_answer_id_provided_by_user,
subanswer_provided_by_user,
explain_answer_provided_by_user,
answer_provided_by_user_was_correct,
quiz_passed_by_user,
quiz_completed_by_user,
answer_provided_by_user,
quiz_type,
answer_order_provided_by_user,
description
;

 

first_last:
NoConcatenate LOAD
user_id, quiz_id, segment_id,
min(quiz_date) as first_attempt,
max(quiz_date) as last_attempt
RESIDENT Quiz
GROUP BY user_id, quiz_id, segment_id
;

left join(first_last):
Load * Resident Quiz;

drop table Quiz;&lt;/PRE&gt;</description>
    <pubDate>Thu, 17 Jan 2019 13:31:54 GMT</pubDate>
    <dc:creator>pasi_lehtinen</dc:creator>
    <dc:date>2019-01-17T13:31:54Z</dc:date>
    <item>
      <title>Min/Max Attempt</title>
      <link>https://community.qlik.com/t5/App-Development/Min-Max-Attempt/m-p/1531563#M38270</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;I am trying to get the first and last attempts&amp;nbsp;for surveys&amp;nbsp;. Right now a user could take a survey 6 times, but I only want their 1st, 6th, or both of those attempts.&amp;nbsp;I need their first and last response per segment_id, otherwise I would lose the other quiz_id's/segment_id's they engaged with.&amp;nbsp; Bellow, is the table that logs all our survey data.&lt;/P&gt;&lt;P&gt;Quiz:&lt;BR /&gt;LOAD quiz_id,&lt;BR /&gt;quiz_name,&lt;BR /&gt;quiz_date,&lt;BR /&gt;segment_id,&lt;BR /&gt;user_id,&lt;BR /&gt;site_id as quiz_site,&lt;BR /&gt;test_type,&lt;BR /&gt;question,&lt;BR /&gt;question_order,&lt;BR /&gt;answer_order as order,&lt;BR /&gt;answer_or_sub_question,&lt;BR /&gt;question_id,&lt;BR /&gt;solution_id,&lt;BR /&gt;solution_answer_id_provided_by_user,&lt;BR /&gt;subanswer_provided_by_user,&lt;BR /&gt;explain_answer_provided_by_user,&lt;BR /&gt;answer_provided_by_user_was_correct,&lt;BR /&gt;quiz_passed_by_user,&lt;BR /&gt;quiz_completed_by_user,&lt;BR /&gt;answer_provided_by_user,&lt;BR /&gt;quiz_type,&lt;BR /&gt;answer_order_provided_by_user,&lt;BR /&gt;description&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here was my attempt at it:&lt;/P&gt;&lt;P&gt;RIGHT JOIN (Quiz)&lt;/P&gt;&lt;P&gt;first_last:&lt;BR /&gt;LOAD&lt;BR /&gt;*,&lt;BR /&gt;min(quiz_date) as first_attempt,&lt;BR /&gt;max(quiz_date) as last_attempt&lt;/P&gt;&lt;P&gt;RESIDENT Quiz&lt;BR /&gt;WHERE (min(quiz_date) = quiz_date OR max(quiz_date) = quiz_date)&lt;BR /&gt;GROUP BY user_id, quiz_id, segment_id&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;I think I may need something similar to a self join here since the&amp;nbsp;WHERE should only apply to a user within a quiz_id/segment_id. I am getting a very vague "general load error" when running this. I appreciate any help.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2019 13:18:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Min-Max-Attempt/m-p/1531563#M38270</guid>
      <dc:creator>blpetosa</dc:creator>
      <dc:date>2019-01-17T13:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Min/Max Attempt</title>
      <link>https://community.qlik.com/t5/App-Development/Min-Max-Attempt/m-p/1531587#M38277</link>
      <description>&lt;P&gt;Please try this:&lt;/P&gt;&lt;PRE&gt;Quiz:
LOAD quiz_id,
quiz_name,
quiz_date,
segment_id,
user_id,
site_id as quiz_site,
test_type,
question,
question_order,
answer_order as order,
answer_or_sub_question,
question_id,
solution_id,
solution_answer_id_provided_by_user,
subanswer_provided_by_user,
explain_answer_provided_by_user,
answer_provided_by_user_was_correct,
quiz_passed_by_user,
quiz_completed_by_user,
answer_provided_by_user,
quiz_type,
answer_order_provided_by_user,
description
;

 

first_last:
NoConcatenate LOAD
user_id, quiz_id, segment_id,
min(quiz_date) as first_attempt,
max(quiz_date) as last_attempt
RESIDENT Quiz
GROUP BY user_id, quiz_id, segment_id
;

left join(first_last):
Load * Resident Quiz;

drop table Quiz;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Jan 2019 13:31:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Min-Max-Attempt/m-p/1531587#M38277</guid>
      <dc:creator>pasi_lehtinen</dc:creator>
      <dc:date>2019-01-17T13:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: Min/Max Attempt</title>
      <link>https://community.qlik.com/t5/App-Development/Min-Max-Attempt/m-p/1533275#M38407</link>
      <description>&lt;P&gt;Sorry for the late response, especially after your quick one. I have been OOO. This worked really well for what I needed. I did need more of a tag mechanism, but I didn't communicate that in the original post. Now I can query by the first or last attempt. I added this after&amp;nbsp;what you sent:&lt;/P&gt;&lt;P&gt;first_last2:&lt;BR /&gt;Load&lt;BR /&gt;*,&lt;BR /&gt;if(first_attempt=solution_id,1,&lt;BR /&gt;if(last_attempt=solution_id,2,0)) as first_last&lt;BR /&gt;RESIDENT first_last&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;DROP TABLE first_last;&lt;/P&gt;&lt;P&gt;I originally tried a preceding LOAD, but it didn't like that with the "NoConcatenate LOAD"there. solution_id was also better to use than quiz_date, but that was my fault. Regardless, thank you for your help with this!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 13:24:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Min-Max-Attempt/m-p/1533275#M38407</guid>
      <dc:creator>blpetosa</dc:creator>
      <dc:date>2019-01-22T13:24:16Z</dc:date>
    </item>
  </channel>
</rss>

