Knacks woeful calculations #207
Replies: 2 comments
-
Hi Michael, That equation is quite impressive! Doing this in Knack is... pretty much impossible, I think. And extremely hard to troubleshoot if something doesn't work as expected. But it can be done quite easily in Javascript. I've been brainstorming with Charles on how to implement complex conditions with the ktlCond kw option. Example:
The new option ktlFunc is key here. It tells the keyword to jump in the function that follows to get the comparison value to be used. In this case, it would add the class dangerClass (red on yellow, flashing for ex) to a water field in a details view, when the function percentageToxicity returns a value more than 5. In your code, the function percentageToxicity can reach any level of complexity you need. Of course, this would bring us back to Javascript coding, which is the devil in person for most users, but at least, you only need to concentrate on the "simple" if/then/else syntax, just like in any other language. That complexity is not any worse that what you have in your example above. With a few good examples, I think most of them would be able to figure it out. Food for thoughts... |
Beta Was this translation helpful? Give feedback.
-
Thanks Norm! I'm just glad to hear it might be possible _ I think I'll wait for your ktlFunc to be live and try it out with one of our simpler forms |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Norm,
Been implementing some of your recent stuff - so so good thank you - favourite recent thing is the tooltip :)
KTL seems great at resolving some of the things that hold knack back so I thought I would broach this subject on calculations generally which I see as Knacks main draw back - it is woeful at calculations and in particular logic based calculations that might depend on a number of changeable parameters.
If you want to use knack to calculate several possible outcomes you need to
And you need to be careful about what order you put things in as Knack will calculate fields top to bottom - it will produce unreliable rsults if you miss something there and it might not be obvious that you have
Meanwhile other similar programs can do all calculations in one field - for some of our work we use cognito forms - not a great database tool but is fantastic at calculations - heres an example - this is all done in one field in Cognito Forms
=if Analyte = "Asbestos" then (if LabResult = null then null else if (LabResult.ToLower.Contains("chrysotile") and LabResult.ToLower.Contains("amosite") and LabResult.ToLower.Contains("crocidolite")) then "Chrysotile, Amosite & Crocidolite Asbestos Detected" else if (LabResult.ToLower.Contains("chrysotile") and LabResult.ToLower.Contains("amosite")) then "Chrysotile & Amosite Asbestos Detected" else if (LabResult.ToLower.Contains("chrysotile") and LabResult.ToLower.Contains("crocidolite")) then "Chrysotile & Crocidolite Asbestos Detected" else if (LabResult.ToLower.Contains("amosite") and LabResult.ToLower.Contains("crocidolite")) then "Amosite & Crocidolite Asbestos Detected" else if (LabResult.ToLower.Contains("chrysotile")) then "Chrysotile Asbestos Detected" else if (LabResult.ToLower.Contains("amosite")) then "Amosite Asbestos Detected" else if (LabResult.ToLower.Contains("crocidolite")) then "Crocidolite Asbestos Detected" else if (LabResult.ToLower.Contains("unidentified mineral fibres") or LabResult.ToLower.Contains("unknown mineral fibre")) then "Unidentified Mineral Fibres Detected" else if (LabResult.ToLower.Contains("synthetic")) then "Synthetic Mineral Fibres (No Asbestos) Detected" else if (LabResult.ToLower.Contains("no asbestos")) then "No Asbestos Detected" else null) else if Analyte = "Lead Paint" then (if LabResult2 = null then null else if LabResult2100 >0.1 then "Positive: Lead in Paint = " + LabResult2 + " (> 0.1%)" else if LabResult2100 <0.1 then "Negative: Lead in Paint = " + LabResult2 + " (< 0.1%)" else if LabResult2=0.1 then "Positive: Lead in Paint = 0.1% (equal to the guideline level)" else null) else if Analyte = "Lead Dust" then (if LabResult3 = null then null else if LabResult3 >80 then "Positive: Lead in Dust = " + LabResult3/10 + "mg/m² (> 8mg/m²)" else if LabResult3 <80 then "Negative: Lead in Dust = " + LabResult3/10 + "mg/m² (< 8mg/m²)" else if LabResult3 =80 then "Positive: Lead in Dust = 8mg/m² (equal to the guideline level)" else null) else null
Can you imagine trying to do this in Knack??
The ktlCond has many of the logic functions needed for most calculations - could this be adapted to produce a result in a field based on other field entries?
Could it operate in real time based on the entry of other fields?
It would need to be able to operate with an
if ... then ... else ....
type format to be powerful
If I could do the above in Knack I would move everything across because of Knacks other advantages
Beta Was this translation helpful? Give feedback.
All reactions