dynamics ax 2012 - How to sum a field using some conditions in Axapta? -


i have user table this

  id     date        value   ---------------------------   1001   31 01 14    2035.1   1002   31 01 14    1384.65   1003   31 01 14    1011.1   1004   31 01 14    1187.04   1001   28 02 14    2035.1   1002   28 02 14    1384.65   1003   28 02 14    1011.1   1004   28 02 14    1188.86   1001   31 03 14    2035.1   1002   31 03 14    1384.65   1003   31 03 14    1011.1   1004   31 03 14    1188.86   1001   30 04 14    2066.41   1002   30 04 14    1405.95   1003   30 04 14    1026.66   1004   30 04 14    1207.15 

and want make sum table this

  id     date        value       total   ---------------------------------------   1001   31 01 14    2035.1     2035.1   1002   31 01 14    1384.65    1384.65   1003   31 01 14    1011.1     1011.1   1004   31 01 14    1187.04    1187.04   1001   28 02 14    2035.1     4070.2   1002   28 02 14    1384.65    2769.3   1003   28 02 14    1011.1     2022.2   1004   28 02 14    1188.86    2375.9   1001   31 03 14    2035.1     6105.3   1002   31 03 14    1384.65    4153.95   1003   31 03 14    1011.1     3033.3   1004   31 03 14    1188.86    3564.76   1001   30 04 14    2066.41    8171.71   1002   30 04 14    1405.95    5180.61   1003   30 04 14    1026.66    4059.96   1004   30 04 14    1207.15    4771.91 

i have id, each id first month should write value total , second month of id, should add value of first month + second month , should go on this. how can summation in x++?

can me?

it can done display method on table:

display amount total() {     return (select sum(value) of table                  table.id == this.id &&                       table.date <= this.date).value; } 

change table , field names fit.

this may not fastest way though. in report context, might better keep running total each id (in map).

also can done in select this:

table table1, table2 while select table1     group date, id, value     inner join sum(value) of table2      table2.id == table1.id &&           table2.date <= table1.date {     ... } 

you need group on wanted fields, because aggregate select.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -