<?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 Expression to populate a missing ratio when underlying values are present and reasonable in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Expression-to-populate-a-missing-ratio-when-underlying-values/m-p/798563#M666003</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, can someone tell me what might be off with this expression?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All of the data is present in one table, and I see the component values side-by-side in the table.&amp;nbsp; I could write an expression on the straight table, but want it in the script so I don't have to update various tables.&amp;nbsp; The below expression lets the source values through, but isn't populating the missing values like I'd like.&amp;nbsp; I have this working okay for BMI when height/weight are present, but below is a bit more complicated on its validation effort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cholesterol Ratio is just Total Cholesterol divided by HDL.&amp;nbsp; My expression below is evaluating the source data's cholesterol ratios [ZCholesterol Ratio] at that stage) and if it's missing or impossible for a user, it then checks to see if Total Cholesterol and HDL are present and possible, and a little check to be sure the components of Total Cholesterol don't add up to more than the Total Cholesterol.&amp;nbsp; (I only wanted to populate missing values if the data in the calculation was reasonably clean.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No syntax errors, and the script runs okay.&amp;nbsp; I'm just not seeing the missing cholesterol ratios populated and will be calculating them in excel for the moment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load *,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Round(if(([ZCholesterol Ratio]&amp;lt;1 OR len([ZCholesterol Ratio])=0 OR [ZCholesterol Ratio]='') AND [Total Cholesterol]&amp;gt;0 AND [Total Cholesterol]&amp;lt;5000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND HDL&amp;gt;1 AND HDL&amp;lt;[Total Cholesterol] AND ((HDL+LDL+(Triglycerides/5))&amp;lt;=([Total Cholesterol]+4)), [Total Cholesterol]/HDL, [ZCholesterol Ratio]),.1) as [Cholesterol Ratio]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //the +4 near the end of this statement is to allow for very sleight rounding errors on each of the three component values.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Jan 2015 19:32:36 GMT</pubDate>
    <dc:creator>stevelord</dc:creator>
    <dc:date>2015-01-15T19:32:36Z</dc:date>
    <item>
      <title>Expression to populate a missing ratio when underlying values are present and reasonable</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-to-populate-a-missing-ratio-when-underlying-values/m-p/798563#M666003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, can someone tell me what might be off with this expression?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All of the data is present in one table, and I see the component values side-by-side in the table.&amp;nbsp; I could write an expression on the straight table, but want it in the script so I don't have to update various tables.&amp;nbsp; The below expression lets the source values through, but isn't populating the missing values like I'd like.&amp;nbsp; I have this working okay for BMI when height/weight are present, but below is a bit more complicated on its validation effort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cholesterol Ratio is just Total Cholesterol divided by HDL.&amp;nbsp; My expression below is evaluating the source data's cholesterol ratios [ZCholesterol Ratio] at that stage) and if it's missing or impossible for a user, it then checks to see if Total Cholesterol and HDL are present and possible, and a little check to be sure the components of Total Cholesterol don't add up to more than the Total Cholesterol.&amp;nbsp; (I only wanted to populate missing values if the data in the calculation was reasonably clean.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No syntax errors, and the script runs okay.&amp;nbsp; I'm just not seeing the missing cholesterol ratios populated and will be calculating them in excel for the moment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load *,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Round(if(([ZCholesterol Ratio]&amp;lt;1 OR len([ZCholesterol Ratio])=0 OR [ZCholesterol Ratio]='') AND [Total Cholesterol]&amp;gt;0 AND [Total Cholesterol]&amp;lt;5000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND HDL&amp;gt;1 AND HDL&amp;lt;[Total Cholesterol] AND ((HDL+LDL+(Triglycerides/5))&amp;lt;=([Total Cholesterol]+4)), [Total Cholesterol]/HDL, [ZCholesterol Ratio]),.1) as [Cholesterol Ratio]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //the +4 near the end of this statement is to allow for very sleight rounding errors on each of the three component values.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jan 2015 19:32:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-to-populate-a-missing-ratio-when-underlying-values/m-p/798563#M666003</guid>
      <dc:creator>stevelord</dc:creator>
      <dc:date>2015-01-15T19:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Expression to populate a missing ratio when underlying values are present and reasonable</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-to-populate-a-missing-ratio-when-underlying-values/m-p/798564#M666004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you sure the LDL and Triglycerides fields contain values too? You don't check for nulls there. Does the expression work in a straight table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW, I think you can use the alt function instead of the OR checks:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load *,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Round(if(&lt;STRONG&gt;Alt([ZCholesterol Ratio],1)&amp;lt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND [Total Cholesterol]&amp;gt;0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND [Total Cholesterol]&amp;lt;5000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND HDL&amp;gt;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND HDL&amp;lt;[Total Cholesterol]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND ((HDL+LDL+(Triglycerides/5))&amp;lt;=([Total Cholesterol]+4)),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Total Cholesterol]/HDL,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ZCholesterol Ratio]),.1) as [Cholesterol Ratio]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2015 09:35:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-to-populate-a-missing-ratio-when-underlying-values/m-p/798564#M666004</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2015-01-16T09:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Expression to populate a missing ratio when underlying values are present and reasonable</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-to-populate-a-missing-ratio-when-underlying-values/m-p/798565#M666005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gysbert, some records did and some didn't have ldl and triglyceride values; and neither is getting the Cholesterol Ratio which had me scratching my head.&amp;nbsp; I've been scrutinizing timestamps and things to see if anything is keeping them off the same row in the background or whatnot and found nothing there.&amp;nbsp; I figured that last check would treat the nulls as 0s or not worry about them.&amp;nbsp; I actually added the +4 to let negligible rounding errors through when I saw an otherwise perfectly good record overshoot the expected total by a couple of points, and the cr still wouldn't calculate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not a doctor, but I think medically it is possible for people to measure total cholesterol, then hdl, and maybe not have done tests for or recorded ldl and triglyceride values.&amp;nbsp; That last check was just a smell test to see if anything crazy was in the data and skip that record if so.&amp;nbsp; (I didn't want to populate new values with bad data and make more bad data.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm going to try dropping that last check or maybe some simpler ways of writing out the expression to see what happens.&amp;nbsp; (There are filters checking for humanly possible values on individual metrics coming in, so there shouldn't be too much bad left standing.)&amp;nbsp; Thanks for the Alt function too.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2015 15:51:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-to-populate-a-missing-ratio-when-underlying-values/m-p/798565#M666005</guid>
      <dc:creator>stevelord</dc:creator>
      <dc:date>2015-01-16T15:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Expression to populate a missing ratio when underlying values are present and reasonable</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-to-populate-a-missing-ratio-when-underlying-values/m-p/798566#M666006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh yeah, everything works fine when I do it in excel, and I expect it would work fine if I just did a this/that expression on a straight table in qlikview.&amp;nbsp; Effort to make it a complete field in script was more for best practice sake of not having to use straight tables to finish populating values in a field. &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2015 15:55:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-to-populate-a-missing-ratio-when-underlying-values/m-p/798566#M666006</guid>
      <dc:creator>stevelord</dc:creator>
      <dc:date>2015-01-16T15:55:41Z</dc:date>
    </item>
  </channel>
</rss>

