<?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: FirstSortedValue by Subtotal in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433421#M96811</link>
    <description>&lt;P&gt;Hi again. Thanks again for the help thus far. This doesn't appear to be the results I'm looking for..&lt;BR /&gt;The first expression isn't needed (diagnosis from the latest claim).&lt;BR /&gt;The second expression is not returning the diagnosis with the highest total cost.&lt;BR /&gt;Member 1 is showing Diabetes as the highest costing 'Current' diagnosis for this type '1' member. The total cost for Diabetes is 100, compared to the total cost for Chron's being 150 (75 + 75, or claim 12 + claim 13).&lt;/P&gt;</description>
    <pubDate>Thu, 21 Mar 2024 18:03:03 GMT</pubDate>
    <dc:creator>Naude716</dc:creator>
    <dc:date>2024-03-21T18:03:03Z</dc:date>
    <item>
      <title>FirstSortedValue by Subtotal</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2432578#M96744</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;I'm relatively new to QlikSense. I have what I hope to be a pretty simple question.&lt;/P&gt;
&lt;P&gt;I would like to make a table for the top DIAGNOSIS a member has by COST.&lt;/P&gt;
&lt;P&gt;My data-set looks like this:&lt;/P&gt;
&lt;TABLE width="490px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;MEMBER_ID&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;CLAIM_ID&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;DIAGNOSIS&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;COST&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;PERIOD&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;TYPE&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;1&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;11&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Diabetes&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;100&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Current&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;1&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;12&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Chron's&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;75&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Current&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;1&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;13&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Chron's&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;75&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Current&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;2&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;31&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Obesity&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;100&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Current&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;2&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;32&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Obesity&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;200&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Current&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;2&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;33&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Diabetes&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;125&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Current&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;2&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;34&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Bronchitis&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;300&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Prior&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;3&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;41&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Cataracts&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;5&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Current&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;More specifically, I want to return the top DIAGNOSIS summed by COST , for TYPE '1' members in the 'Current' PERIOD.&lt;/P&gt;
&lt;P&gt;That being said, the resulting table I would like to create would look like this:&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="106px" height="19" class="xl67" style="height: 14.5pt; width: 48pt;"&gt;MEMBER_ID&lt;/TD&gt;
&lt;TD width="141px" class="xl67" style="width: 48pt;"&gt;TOP_DIAGNOSIS&lt;/TD&gt;
&lt;TD width="148px" height="25px"&gt;Total_Current_Cost&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="106px" height="19" align="right" style="height: 14.5pt;"&gt;1&lt;/TD&gt;
&lt;TD width="141px"&gt;Chron's&lt;/TD&gt;
&lt;TD width="148px" height="25px"&gt;250&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="106px" height="19" align="right" style="height: 14.5pt;"&gt;2&lt;/TD&gt;
&lt;TD width="141px"&gt;Obesity&lt;/TD&gt;
&lt;TD width="148px" height="25px"&gt;425&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;SPAN&gt;So far I have this formula which&amp;nbsp;&lt;/SPAN&gt;&lt;EM style="font-family: inherit;"&gt;almost&lt;/EM&gt;&lt;SPAN&gt; works for the TOP_DIAGNOSIS column.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;=Aggr(FirstSortedValue({&amp;lt;PERIOD= {'Current'}, TYPE={'1'} &amp;gt;} DIAGNOSIS, -COST),MEMBER_ID)&lt;/P&gt;
&lt;P&gt;This formula returns the following column for this table:&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse;" border="0" width="395px" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="106px" height="19" class="xl67" style="height: 14.5pt; width: 48pt;"&gt;MEMBER_ID&lt;/TD&gt;
&lt;TD width="141px" class="xl67" style="width: 48pt;"&gt;TOP_DIAGNOSIS&lt;/TD&gt;
&lt;TD width="148px" height="25px"&gt;Total_Current_Cost&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="106px" height="19" align="right" style="height: 14.5pt;"&gt;1&lt;/TD&gt;
&lt;TD width="141px"&gt;Diabetes&lt;/TD&gt;
&lt;TD width="148px" height="25px"&gt;250&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="106px" height="19" align="right" style="height: 14.5pt;"&gt;2&lt;/TD&gt;
&lt;TD width="141px"&gt;Obesity&lt;/TD&gt;
&lt;TD width="148px" height="25px"&gt;425&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thus, I believe my formula is looking claim by claim (row by row) showing the highest cost by diagnosis, and not summing up by diagnosis first.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;TLDR:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;How can I subtotal 'DIAGNOSIS' by 'COST' before returning the top 'DIAGNOSIS' by 'COST'?&lt;/P&gt;
&lt;P&gt;Thanks in advance&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 21:45:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2432578#M96744</guid>
      <dc:creator>Naude716</dc:creator>
      <dc:date>2024-03-19T21:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue by Subtotal</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433123#M96783</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Could you please explain how 425 will be the Total Current Cost for obesity?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 06:16:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433123#M96783</guid>
      <dc:creator>pallavi_96</dc:creator>
      <dc:date>2024-03-21T06:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue by Subtotal</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433140#M96787</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;in the FirstSortedValue function you need to sort rows by Claim ID in descending order&lt;BR /&gt;&lt;SPAN&gt;=Aggr(FirstSortedValue({&amp;lt;PERIOD= {'Current'}, TYPE={'1'} &amp;gt;} DIAGNOSIS, -CLAIM_ID),MEMBER_ID)&lt;BR /&gt;&lt;/SPAN&gt;so for member ID = 1, the first sorted value Diagnosis ordered by CLAIM_ID is descending order is 13&lt;BR /&gt;i.e. Chron's&lt;/P&gt;
&lt;P&gt;you wrote:&lt;BR /&gt;&lt;SPAN&gt;=Aggr(FirstSortedValue({&amp;lt;PERIOD= {'Current'}, TYPE={'1'} &amp;gt;} DIAGNOSIS, -COST),MEMBER_ID)&lt;BR /&gt;&lt;/SPAN&gt;so this will return for Member ID =1, the first row ordered by COST in desceinding order i.e. 100 which means Diabetes&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 07:20:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433140#M96787</guid>
      <dc:creator>ali_hijazi</dc:creator>
      <dc:date>2024-03-21T07:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue by Subtotal</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433337#M96799</link>
      <description>&lt;P&gt;Certainly, I should've been more specific. This column is the sum of all cost for this member in the 'Current' period.&lt;/P&gt;
&lt;P&gt;sum(if(Period='Current', COST))&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 14:02:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433337#M96799</guid>
      <dc:creator>Naude716</dc:creator>
      <dc:date>2024-03-21T14:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue by Subtotal</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433339#M96800</link>
      <description>&lt;P&gt;then you need to ignore the DIAGNOSIS dimension and aggr only by member using the "total"&lt;BR /&gt;so your expression would be&amp;nbsp;&lt;BR /&gt;sum(total&amp;lt;MEMBER_ID&amp;gt;{&amp;lt;PERIOD={[CURRENT]}&amp;gt;}COST)&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 13:52:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433339#M96800</guid>
      <dc:creator>ali_hijazi</dc:creator>
      <dc:date>2024-03-21T13:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue by Subtotal</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433358#M96801</link>
      <description>&lt;P&gt;Thank you for your responses Ali_hijazi!&lt;/P&gt;
&lt;P&gt;**this is in response to your initial reply**&lt;/P&gt;
&lt;P&gt;Yes, sorting by CLAIM_ID descending would work for my example, but I need the TOP_DIAGNOSIS to return the highest DIAGNOSIS by total COST for that DIAGNOSIS. In actuality, the data will not have CLAIM_ID's in order like this.&lt;/P&gt;
&lt;P&gt;For instance, say I have another row;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 288pt;" border="0" width="384" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="64" height="19" style="height: 14.5pt; width: 48pt;"&gt;MEMBER_ID&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;CLAIM_ID&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;DIAGNOSIS&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;COST&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;PERIOD&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;TYPE&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.5pt;"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;14&lt;/TD&gt;
&lt;TD&gt;Infection&lt;/TD&gt;
&lt;TD align="right"&gt;5&lt;/TD&gt;
&lt;TD&gt;Current&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this row was added, then 'Infection' would be the 'TOP_DIAGNOSIS', when it's COST is only '5'.&lt;/P&gt;
&lt;P&gt;Is there a way to SUM the DIAGNOSIS by member before sorting by cost, or is there perhaps a better way to do this other than using the FirstSortedValue() function?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 15:09:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433358#M96801</guid>
      <dc:creator>Naude716</dc:creator>
      <dc:date>2024-03-21T15:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue by Subtotal</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433377#M96803</link>
      <description>&lt;P&gt;Kindly show me in a table the expected result form the given data above&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 15:21:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433377#M96803</guid>
      <dc:creator>ali_hijazi</dc:creator>
      <dc:date>2024-03-21T15:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue by Subtotal</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433383#M96806</link>
      <description>&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="106px" height="19" class="xl67"&gt;MEMBER_ID&lt;/TD&gt;
&lt;TD width="141px" class="xl67"&gt;TOP_DIAGNOSIS&lt;/TD&gt;
&lt;TD width="148px" height="25px"&gt;Total_Current_Cost&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106px" height="19" align="right"&gt;1&lt;/TD&gt;
&lt;TD width="141px"&gt;Chron's&lt;/TD&gt;
&lt;TD width="148px" height="25px"&gt;250&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106px" height="19" align="right"&gt;2&lt;/TD&gt;
&lt;TD width="141px"&gt;Obesity&lt;/TD&gt;
&lt;TD width="148px" height="25px"&gt;425&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like Chron's to show for member 1 because it's total summed cost is 150 (out of the total CURRENT cost of 250 for Member 1), and likewise, obesity for member 2.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 15:38:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433383#M96806</guid>
      <dc:creator>Naude716</dc:creator>
      <dc:date>2024-03-21T15:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue by Subtotal</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433386#M96808</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ali_hijazi_0-1711036094930.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/162489iD12EB79D451CF566/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ali_hijazi_0-1711036094930.png" alt="ali_hijazi_0-1711036094930.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;first expression for the diagnosis of the latest claim:&lt;BR /&gt;=Aggr(FirstSortedValue({&amp;lt;PERIOD= {'Current'}, TYPE={'1'} &amp;gt;} DIAGNOSIS, -CLAIM_ID),MEMBER_ID)&lt;BR /&gt;&lt;BR /&gt;second expression for diagnosis with the highest cost:&lt;BR /&gt;=MAXSTRING(Aggr(FirstSortedValue({&amp;lt;PERIOD= {'Current'}, TYPE={'1'},CLAIM_ID={"=COST=MAX(COST)"}&amp;gt;} DIAGNOSIS, CLAIM_ID),MEMBER_ID,DIAGNOSIS))&lt;BR /&gt;&lt;BR /&gt;third expression for the total:&lt;BR /&gt;SUM(TOTAL&amp;lt;MEMBER_ID&amp;gt;{&amp;lt;PERIOD= {'Current'}, TYPE={'1'} &amp;gt;}COST)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 15:49:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433386#M96808</guid>
      <dc:creator>ali_hijazi</dc:creator>
      <dc:date>2024-03-21T15:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue by Subtotal</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433421#M96811</link>
      <description>&lt;P&gt;Hi again. Thanks again for the help thus far. This doesn't appear to be the results I'm looking for..&lt;BR /&gt;The first expression isn't needed (diagnosis from the latest claim).&lt;BR /&gt;The second expression is not returning the diagnosis with the highest total cost.&lt;BR /&gt;Member 1 is showing Diabetes as the highest costing 'Current' diagnosis for this type '1' member. The total cost for Diabetes is 100, compared to the total cost for Chron's being 150 (75 + 75, or claim 12 + claim 13).&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 18:03:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433421#M96811</guid>
      <dc:creator>Naude716</dc:creator>
      <dc:date>2024-03-21T18:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue by Subtotal</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433423#M96812</link>
      <description>&lt;TABLE width="490px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;MEMBER_ID&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;CLAIM_ID&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;DIAGNOSIS&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;COST&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;PERIOD&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;CATG&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;1&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;987&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Diabetes&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;100&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Current&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;1&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;172&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Chron's&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;75&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Current&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;1&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;737&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Chron's&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;85&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Current&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;1&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;146&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Infection&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;5&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Current&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;2&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;314&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Obesity&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;100&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Current&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;2&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;932&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Obesity&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;200&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Current&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;2&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;363&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Diabetes&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;125&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Current&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;2&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;342&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Bronchitis&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;300&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Prior&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106.125px" height="25px"&gt;3&lt;/TD&gt;
&lt;TD width="94.4375px" height="25px"&gt;415&lt;/TD&gt;
&lt;TD width="99.9062px" height="25px"&gt;Cataracts&lt;/TD&gt;
&lt;TD width="55.4531px" height="25px"&gt;5&lt;/TD&gt;
&lt;TD width="72.3438px" height="25px"&gt;Current&lt;/TD&gt;
&lt;TD width="60.7344px" height="25px"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;This example data-set might be a little better to work with. I scrambled the CLAIM_ID numbers a bit, added an additional claim and changed the "TYPE" column to be called "CATG" instead (I think TYPE is a reserved name in Qlik).&lt;/P&gt;
&lt;P&gt;The intended resulting table is the same except for the total current cost.&lt;/P&gt;
&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="106px" height="19" class="xl67"&gt;MEMBER_ID&lt;/TD&gt;
&lt;TD width="141px" class="xl67"&gt;TOP_COSTING_DIAGNOSIS&lt;/TD&gt;
&lt;TD width="148px" height="25px"&gt;Total_Current_Cost_Overall&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106px" height="19" align="right"&gt;1&lt;/TD&gt;
&lt;TD width="141px"&gt;Chron's&lt;/TD&gt;
&lt;TD width="148px" height="25px"&gt;265&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="106px" height="19" align="right"&gt;2&lt;/TD&gt;
&lt;TD width="141px"&gt;Obesity&lt;/TD&gt;
&lt;TD width="148px" height="25px"&gt;425&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 18:49:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433423#M96812</guid>
      <dc:creator>Naude716</dc:creator>
      <dc:date>2024-03-21T18:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue by Subtotal</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433706#M96837</link>
      <description>&lt;P&gt;hello&lt;/P&gt;
&lt;P&gt;to get the diagnosis with max cost as a sum this would solve it:&lt;/P&gt;
&lt;DIV&gt;maxstring&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; {&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PERIOD= {[Current]}&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; , TYPE={[1]}&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,MEMBER_DIAGNOSIS_ID={"=min(aggr(rank(sum({&amp;lt;PERIOD= {[Current]}, TYPE={[1]}&amp;gt;}COST)),MEMBER_ID,DIAGNOSIS))=1"}&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DIAGNOSIS&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; )&lt;/DIV&gt;
&lt;P&gt;{[1]}&amp;gt;}COST)),MEMBER_ID,DIAGNOSIS))=1"}&amp;gt;}DIAGNOSIS)&lt;BR /&gt;&lt;BR /&gt;where MEMBER_DIAGNOSIS_ID is a new field created as follows:&lt;BR /&gt;AutoNumberHash256(MEMBER_ID, DIAGNOSIS) AS MEMBER_DIAGNOSIS_ID;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ali_hijazi_0-1711106011183.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/162555i2FAB111A49131512/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ali_hijazi_0-1711106011183.png" alt="ali_hijazi_0-1711106011183.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2024 11:24:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-by-Subtotal/m-p/2433706#M96837</guid>
      <dc:creator>ali_hijazi</dc:creator>
      <dc:date>2024-03-22T11:24:16Z</dc:date>
    </item>
  </channel>
</rss>

