jeudi 2 février 2017

calculating and inserting values in a result table

ReportingCategory   Title   SubtotalGroup   GroupBreakCon   Actual
 Income Statement new BI    INCOME  1   0   NULL
 Income Statement new BI    Levy income NULL    0   -483541.57
 Income Statement new BI    Levy income NULL    0   -657131.06
 Income Statement new BI    Levy income NULL    0   -184526.04
 Income Statement new BI    Levy income NULL    0   -338064.92
 Income Statement new BI    Levy income NULL    0   -110019.3
 Income Statement new BI    Levy income NULL    0   -529367.5
 Income Statement new BI    Levy income NULL    0   -22501.73
 Income Statement new BI    Levy income NULL    0   -123021.98
 Income Statement new BI    Levy income NULL    0   -9927.83
 Income Statement new BI    Levy income NULL    0   -95300.19
 Income Statement new BI    Levy income NULL    0   -135235.24
 Income Statement new BI    Levy income NULL    0   -439673.25
 Income Statement new BI    Levy income NULL    0   -41530.53
 Income Statement new BI    Levy income NULL    0   -394361.39
 Income Statement new BI    Levy income NULL    0   -902.5
 Income Statement new BI    Levy income NULL    0   0
 Income Statement new BI    Levy income NULL    0   0
 Income Statement new BI    Levy income NULL    0   -7.72
 Income Statement new BI    Levy income NULL    0   -11961.34
 Income Statement new BI    Levy income NULL    0   -60589.64
 Income Statement new BI    Levy income NULL    0   0
 Income Statement new BI    Levy income NULL    0   -3828.74
 Income Statement new BI    Levy income NULL    0   -143189.58
 Income Statement new BI    Levy income NULL    0   -800950.83
 Income Statement new BI    Levy income NULL    0   0
 Income Statement new BI    Levy income NULL    0   580.27
 Income Statement new BI    Levy income NULL    0   -78141.85
 Income Statement new BI    Levy income NULL    0   -358986.95
 Income Statement new BI    Consultancy Fees    NULL    0   -15000
 Income Statement new BI        1   0   NULL
 Income Statement new BI    OTHER INCOME    1   100000000   NULL
 Income Statement new BI        1   100000000   NULL
 Income Statement new BI    TOTAL INCOME    3   200000000   NULL

This is a part of my data set. the column actual is created using sum of transactions from a different table. What I need to show here is that if the Title is empty(not NULL) then the Actual should show the sum of everything which has the same GroupBreakCon.

Also where you can see the TOTAL INCOME in the last row. the Actual should show the sum of both the subgroup totals calculated above.

If we take the above example then the result should be like this

ReportingCategory   Title   SubtotalGroup   GroupBreakCon   Actual
 Income Statement new BI    INCOME  1   0   NULL
 Income Statement new BI    Levy income NULL    0   -483541.57
 Income Statement new BI    Levy income NULL    0   -657131.06
 Income Statement new BI    Levy income NULL    0   -184526.04
 Income Statement new BI    Levy income NULL    0   -338064.92
 Income Statement new BI    Levy income NULL    0   -110019.3
 Income Statement new BI    Levy income NULL    0   -529367.5
 Income Statement new BI    Levy income NULL    0   -22501.73
 Income Statement new BI    Levy income NULL    0   -123021.98
 Income Statement new BI    Levy income NULL    0   -9927.83
 Income Statement new BI    Levy income NULL    0   -95300.19
 Income Statement new BI    Levy income NULL    0   -135235.24
 Income Statement new BI    Levy income NULL    0   -439673.25
 Income Statement new BI    Levy income NULL    0   -41530.53
 Income Statement new BI    Levy income NULL    0   -394361.39
 Income Statement new BI    Levy income NULL    0   -902.5
 Income Statement new BI    Levy income NULL    0   0
 Income Statement new BI    Levy income NULL    0   0
 Income Statement new BI    Levy income NULL    0   -7.72
 Income Statement new BI    Levy income NULL    0   -11961.34
 Income Statement new BI    Levy income NULL    0   -60589.64
 Income Statement new BI    Levy income NULL    0   0
 Income Statement new BI    Levy income NULL    0   -3828.74
 Income Statement new BI    Levy income NULL    0   -143189.58
 Income Statement new BI    Levy income NULL    0   -800950.83
 Income Statement new BI    Levy income NULL    0   0
 Income Statement new BI    Levy income NULL    0   580.27
 Income Statement new BI    Levy income NULL    0   -78141.85
 Income Statement new BI    Levy income NULL    0   -358986.95
 Income Statement new BI    Consultancy Fees    NULL    0   -15000
 Income Statement new BI        1   0   -5037181
 Income Statement new BI    OTHER INCOME    1   100000000   NULL
 Income Statement new BI        1   100000000   0
 Income Statement new BI    TOTAL INCOME    3   200000000   -5037181

please can someone advise how can this be acheived.

Aucun commentaire:

Enregistrer un commentaire