can we get value of above cell of same column of table in ssrs report builder? How?

时光毁灭记忆、已成空白 提交于 2019-12-11 17:58:10

问题


I have edited my question and replace the previous explanation with new one. I think I could't explain my problem clearly before. here is my scenario:

Col1  |Col2  |Col3  |Col4   |Col5  | Col6  
------|------|------|-------|------| 3333.00 (Table 1)  
------|------|------|  15.00|  0.00| 3348.00 (Table 2)  
------|------|------|   0.00|550.00| 2798.00 (Table 2)
     Sub ToTal:-----|  15.00|550.00| 2798.00 (Table 3)

In this report value (3,333.00) of Table 1 is Opening Balance. For Table2 and Table3, col4 is Deposit and Col5 is Withdraw. Last column of Table2 and Table3 are closing balance. So, the rule is, closing balance of first row of Table2 should be calculated as (ClosingBalance = OpeningBalance + Deposit - Withdrawal). and Closing Balance of 1st row should be opening Balance for second row. Table 3 has nothing to do with them.

Now problem is that 3333.00 is coming from query so we can easily calculate 3348.00 but i dont know how to calculate 2798.00 as it required value of above cell which is 3348.00. similarly if Table 2 generate 10 rows than 1st value of last column should be calculated from 3333.00 and remaining rows will calculate their values from above cell i.e 2798.00 depends on 3348.00 and if there is next row than it will depend on 2798.00. so i have done this:

IIf(RowNumber(DatasetName) = 1, value of Table1(3333.00) + and remaining values to calculate 3348.00, Previous(ReportItems!MyTextBoxName.Value) + other values)

Now it gives me error:

The Value expression for the textrun 'Amount8.Paragraphs[0].TextRuns[0]' uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers.

I searched over different forums and found out that I can't use ReportItems in this scenario. So, what should I do?

I know my scenario is complicated and its more complicated to explain it but I tried my best. Please tell me any solution you have.


回答1:


Try Previous(Copy the expression used in your MyTextboxName)




回答2:


You can use Lag function in your SQL Statement to get to previous value.

SELECT Field1, Lag(Field1,1,NULL) OVER(PARTITION BY .... ORDER BY ....)
FROM Table1..... 

Here are couple of articles to help you understand Lag in Detail

Intro to Lead and Lag By Pinal Dave

Lead and Lag function article in DatabaseJournal



来源:https://stackoverflow.com/questions/30058401/can-we-get-value-of-above-cell-of-same-column-of-table-in-ssrs-report-builder-h

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!