Total field divide other total field

瀏覽次數:65 次
跳到第一則未讀訊息

David Martinez

未讀,
2018年1月30日 晚上11:05:462018/1/30
收件者:mementodatabase
I made a Bd for a currency exchange daily operations for example I'm buy euro at rate 1.05 usd the second day im buying other euros at 1.054 the third day buy 1.053 if

100€ x 1.05
88€ x 1.054
150€ x 1.053

I need make this calc(100+88+150)/(1.05+1.054+1.053)

Memento have a function to average but only make a bad averege for prices without amounts this is a problem is a fake average

Excuses for my English I'm leave the same comment in Spanish too.


Hola estoy haciendo una base de datos para una empresa de cambio de divisas por lo que necesito saber los promedios de compra suponiendo que un día compre con una tasa a 1.05 el día siguient 1.054 y el siguiente a 1.053 los siguientes montós

100€ x 1.05
88€ x 1.054
150€ x 1.053
Necesitaría hacer la siguiente operación
(100+88+150)/(1.05+1.054+1.053)

Pero memento me. Saca un promedio pero de los valores s sin tener is n cuenta las cantidades alguna ayuda?

Bill Crews

未讀,
2018年1月31日 凌晨1:59:042018/1/31
收件者:David Martinez、mementodatabase
> I need make this calc(100+88+150)/(1.05+1.054+1.053)

The problem with all questions of this sort is where to store and/or display the results. In aggregation, they are conveniently and dynamically displayed as subtotals on the group bar and as totals on the list bar. If the aggregation functions don't suit you, you can define a library section to do anything you want, but then what did you do with the results? Store all results in every entry? Create a special entry for results? Write the results to a file?

To define a library action, from the entries list screen, 3-dot menu > Scripts > Action. Give it a name, and set it to a library action, not an entry action. Then use your formula...

var entries = lib().entries();
var euros = 0.0, prices = 0.0, avg = 0.0;
for (var ent in entries) {
   var e = entries[ent];
   euros += e.field("Euros");
   prices += e.field("Price");
   }
// Now do SOMETHING with avg = euros / prices
message("Average is " + avg.toFixed(2));

Is this really the average you want?
回覆所有人
回覆作者
轉寄
0 則新訊息