M
Mishanya
My query has Expression field AssetHolding wich sums asset's transactions
multiplied by current price and shows the asset's money-value held in
portfolio.
AssetHolding : Sum([TransactionQuantity]*[CreditDebit]*[CurrentPrice])
where CreditDebit may be 1 or -1 (buy or sell), CurrentPrice updates every
day an AssetHolding' criteria is <>0 (so that, when sold out, the Portfolio
form, based on the query, won't show zero holdings).
It had worked fine untill today, when I encountered very strange behaviour.
Today, having sold out one particular security, I've still recieved zero
value for this asset in the Portfolio form. When placing the mouse-pointer on
the AssetHolding cell the zero turned to microscopical sientifical value
1.45519152283669E-11.
I've run some checks:
1) In the query indeed the AssetHolding is presented as 0 (or
1.45519152283669E-11 when mouse-pointed), but when I put the asset' name as
criteria (in order to limit the query to the asset in question), the query
output is null (no records).
2) In the query I've added TransactionNumber field in order to get every
transaction' value record instead of its sum. Then I copied the results (1
buy and 2 sells) to Excel and sumed it up. The result was 0 (zero), with any
number of the decimal places (wich means the AssetHolding expression in the
query should return excactly 0 with no fractions when sum of
TransactionQuantity bought is equal to the sum of TransactionQuantity sold).
3) In the AssetHolding expression I've eliminated the CurrentPrice part (the
only one wich can have fractional value) - the output became correct (the
sold-out asset disappeared).
4) Finally I've swaped the sell-transactions' quantities. What a wonder!
When the running order of transactions was +68000 (buy), -60000 (sell), -8000
(sell), as it should have been, I had this annoying zero or
1.45519152283669E-11. But having swapped the sell transactions, so it became
+68000 (buy), -8000 (sell), -60000 (sell), the query output became correct.
After all the check-ups I may assume that the problem arises when multiplier
with floating point is involved or when some particular order takes place in
the Sum function calculation. Still, neither of this makes any sense, as
there is no constant pattern in the query behaviour - for some assets it
happens, for others it does not.
What can be done? (other then bending the rebellious query artificially by
putting some IIF((Sum(x)) <.0000000001,0,Sum(x)) criteria)?
multiplied by current price and shows the asset's money-value held in
portfolio.
AssetHolding : Sum([TransactionQuantity]*[CreditDebit]*[CurrentPrice])
where CreditDebit may be 1 or -1 (buy or sell), CurrentPrice updates every
day an AssetHolding' criteria is <>0 (so that, when sold out, the Portfolio
form, based on the query, won't show zero holdings).
It had worked fine untill today, when I encountered very strange behaviour.
Today, having sold out one particular security, I've still recieved zero
value for this asset in the Portfolio form. When placing the mouse-pointer on
the AssetHolding cell the zero turned to microscopical sientifical value
1.45519152283669E-11.
I've run some checks:
1) In the query indeed the AssetHolding is presented as 0 (or
1.45519152283669E-11 when mouse-pointed), but when I put the asset' name as
criteria (in order to limit the query to the asset in question), the query
output is null (no records).
2) In the query I've added TransactionNumber field in order to get every
transaction' value record instead of its sum. Then I copied the results (1
buy and 2 sells) to Excel and sumed it up. The result was 0 (zero), with any
number of the decimal places (wich means the AssetHolding expression in the
query should return excactly 0 with no fractions when sum of
TransactionQuantity bought is equal to the sum of TransactionQuantity sold).
3) In the AssetHolding expression I've eliminated the CurrentPrice part (the
only one wich can have fractional value) - the output became correct (the
sold-out asset disappeared).
4) Finally I've swaped the sell-transactions' quantities. What a wonder!
When the running order of transactions was +68000 (buy), -60000 (sell), -8000
(sell), as it should have been, I had this annoying zero or
1.45519152283669E-11. But having swapped the sell transactions, so it became
+68000 (buy), -8000 (sell), -60000 (sell), the query output became correct.
After all the check-ups I may assume that the problem arises when multiplier
with floating point is involved or when some particular order takes place in
the Sum function calculation. Still, neither of this makes any sense, as
there is no constant pattern in the query behaviour - for some assets it
happens, for others it does not.
What can be done? (other then bending the rebellious query artificially by
putting some IIF((Sum(x)) <.0000000001,0,Sum(x)) criteria)?