HOWTO create a table of variables witch can be edited by QV user?
hellow there,
I`d like to create a bunch of variables (in some kind of structure like table or sth.) witch can be edited by QV user and this variables affects the results presented in application.
The problem is connected with currency exchange defined by every month-year, so the QV app user can edit structure like below:
Table 1.
Currency
Book Month
Rate
USD
2011-06-01
2.75
USD
2011-05-01
2.77
USD
2011-04-01
2.91
USD
2011-03-01
2.94
USD
2011-02-01
2.88
USD
2011-01-01
3.05
EUR
2011-06-01
3.95
EUR
2011-05-01
3.99
TND
2011-04-01
4.06
EUR
2011-03-01
4
GBP
2011-02-01
3.89
EUR
2011-01-01
4
…
Lets say we give him a possibility to select single 'Currency+Book_Month' and then edit 'Rate' using Spinner component.
Looking at the data logic we have a product bouhgt in some date, which contains a parts - each part`s cost is described in different currency with Rate determined by 'Currency' and 'Book_Month' from table above.
For specific product we calcuate real cost transfering all costs in to one currency calculating it using table 'Table 1' and combining it by Table2.'Book date' with Table1.'Book Month' and Table1.'Currency' with Table2.Part_1_Currency, Table2.Part_2_Currency and Table2.Part_3_Currency.
Table 2.
Product_id
Book date
Part_1_Currency
Part_1_Cost
Part_2_Currency
Part_2_Cost
Part_3_Currency
Part_3_Cost
1
2011-06-23
USD
39
EUR
56
TND
75
2
2011-05-04
EUR
56
EUR
78
TND
89
3
2011-02-23
GBP
34
EUR
23
MAD
32
QV User by editing currency rates in 'table 1' can speculate how high product`s cost could be if the currency rate changes. 'Table 1' can be staticly set at the begining and then while changing by user product`s cost will be recalculated.
Questions:
1. how to dynamicly define in QV structure of variables like in 'Table 1' and connect them with QV component, in order to changing them by user, wihout reloading all application? (defining a single variable multiple times and managing it is realy annoying).
2. If we make a pivot with aggregation sum(product`s_cost) how to dynamicly calculate cost_of_all_products while assumpions in 'Table 1' are being changed by QV user? maybe use an external funtion witch takes as args. info about product, then calculates cost based on Table1? But I don`t have a clue if this kind of funtions can be written in qv scripting? maybe it has to be external written in VBA, Python...?