Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
intervigilium
Contributor III
Contributor III

Sequence in expression is having impact on result...?!?

Hi all,

Probably due to the many (()))()( i don't see the error anymore.

 

I have the following expression:
=$(vVerloondeUrenCum) + $(vPrognoseVerloondeUren498Cum)
(result is good)
( both variables give also seperate the right result)

Strange enough if you change the order, the result is different:
=$(vPrognoseVerloondeUren498Cum) + $(vVerloondeUrenCum) 

is giving some other result (only calculatiing first part = $(vPrognoseVerloondeUren498Cum)))

 

Variables:

VVerloondeUrenCum:

(sum({$<ComponentID={498},Kwartaal=,Maand=,MaandNr=>}Loonresultaat))

vPrognoseVerloondeUren498Cum:

 

If(IsNull([DatumUitDienst]),

(($(vVerloondeUrenCum)) / Count(DISTINCT(if(Loonresultaat>0,Periode))))
*
(($(vAantalPeriodes)) - (Round (Num((StatusVerloning.V1+StatusVerloning.V2+StatusVerloning.V3+StatusVerloning.V4+StatusVerloning.V5+StatusVerloning.V6+StatusVerloning.V7+StatusVerloning.V8+StatusVerloning.V9+StatusVerloning.V10+StatusVerloning.V11+StatusVerloning.V12+StatusVerloning.V13) / 8 ,00)))),0)

Anyone?

1 Reply
marcus_sommer

IMO brackets should be only set where they are mandatory to complete (nested) functions or to define a certain order of calculations - everything more is only confusing and error-prone. Therefore I suggest to remove the superfluous ones. The same is true for functions without any usage like your num() in the second variable (each calculation with a formatted number will return an unformatted number).

Beside this an addition should return the same results independent of the order of their operands. But this is only true if the calculation happens within the identical context - each change here even very small ones could impact the results.

Just with this information it's quite hard to say what's wrong with your calculation. A potential issue might be your multiple additions with + because as far as any of the operands contained not a valid number the whole result will be NULL. This might be intended but if not if would be better to use rangesum() for it.

- Marcus