
Field Format and Calculation Problem ?
Neil Miller Oct 5, 2010 11:48 AM (in response to selcuk45)Try:
(fieldA * Num(fieldB))
QlikView is probably treating the fractions as text (or worse, dates). If you use Num() it will evaluate the fraction to a decimal. It may even be a good idea to use the Num() function in your load.
LOAD Num(fieldB) As fieldB
FROM...
Field Format and Calculation Problem ?
John Witherspoon Oct 5, 2010 6:22 PM (in response to Neil Miller)
NMiller wrote:If you use Num() it will evaluate the fraction to a decimal.
Wait, it does? It does! Clever. I had no idea. :)

Field Format and Calculation Problem ?
selcuk45 Oct 6, 2010 4:10 AM (in response to Neil Miller)
Thanks for responsesBut it does not work !!!
Any idea ???
Thanks in advance
Field Format and Calculation Problem ?
Neil Miller Oct 6, 2010 10:56 AM (in response to selcuk45)Sorry, I must have spoken too soon. It seems to work in a text box as Num(1/3), but not when the data is a fraction.
You can use Evaluate(FIELD) in your load and it seems to work. Using Evaluate(FIELD) in an expression does not work though.
EDIT: Maybe because Evaluate is not valid in an expression, only in the load. I attached an example that loads the Fraction and then Evaluates that fraction into a decimal value.
Last Edit, I Promise: I figured out an expression that would do it. It's not pretty, so I would suggest the Evaluate option, but this will probably work fine:
Left(Fraction, Index(Fraction, '/')  1) /
Mid(Fraction, Index(Fraction, '/') + 1)
Fractions.qvw 134.8 K

Field Format and Calculation Problem ?
John Witherspoon Oct 6, 2010 5:06 PM (in response to Neil Miller)I agree that it's probably best to do it in the load, but here's a slightly simpler chart expression that works:
subfield(Fraction,'/',1)/subfield(Fraction,'/',2)
And num(Fraction) not working makes sense to me in hindsight. When you say num(1/3), it's almost certainly just doing a straight division, and only THEN evaluating the num() function. Standard order of precedence stuff, working from inside out, nothing clever. If you do num('1/3'), then it doesn't work, I think indicating that the num() function doesn't actually know what to do with fractions.
As an aside, I'd really like for the evaluate() function to work in chart expressions as well.

Field Format and Calculation Problem ?
Neil Miller Oct 6, 2010 6:07 PM (in response to John Witherspoon )Subfield, yes, much nicer. I'll have to add that one to my cheat sheet, it can really come in handy when working on fields that aren't necessarily delimited lists. Thanks for the tip!

Field Format and Calculation Problem ?
selcuk45 Oct 7, 2010 9:11 AM (in response to Neil Miller)
THANKS FOR RESPONSES...
HAVE A GOOD TIME...




