I am working on a complicated scenario where I need to show a dollar amount of previous lines until a tilde is present. Here is an example :
As per the above example, if the line starts with ~ [tilde], it should show its own retail amount in 'Retail on quote' field. If the line does not start with ~ then the 'Retail on quote' should be blank but subtotal in the background to show it on line with ~ adding tilde line amount as well. Any input will be much appreciated.
You can create the following Stored Procedure in DB and call this procedure in SSRS: (Note: I have used MS SQL Server as a DB and created the similar table in DB as you shown in the example image except column "Retail_On_QUOTE")
create or alter procedure test_sproc
as
begin
create table #tbl1 (col1 char(10), Retail int, Retail_On_QUOTE int)
insert into #tbl1 select Col1, retail, 0 from tbl1
declare c1 cursor for select Col1, retail from #tbl1
declare @total int=0, @col1 char(10), @retail int, @total2 int=0
open c1
fetch next from c1 into @col1, @retail
WHILE @@FETCH_STATUS = 0
begin
if left(@col1,1) = '~'
begin
set @total = @retail+@total2
set @total2 = 0
end
else
begin
set @total2 = @total2+@retail
set @total = 0
end
print @total
update #tbl1 set Retail_On_QUOTE = @total where col1 = @col1
fetch next from c1 into @col1, @retail
end
close c1
deallocate c1
select col1, Retail, Retail_On_QUOTE from #tbl1
end
You could do this in a VB function (Code Section of the Report) and call the function with line name and $ Amount. Add to a sum and return the value to display it. In a second Function you could return the sum and set it to 0.
Not sure this is all correct VB, but it would look something like this:
Public Function SumUp(line As String, value As Double) As Double
sum = sum + value
Return value
End Function
Public Function GetSum() As Double
Dim v = sum
sum = 0
Return sum
End Function
In your Value-Field call the function like this:
=Code!SumUp(Fields!Line, Fields!Value)
In your Sum-Field call the GetSum function in a IIF expression like
=IIF(pseudo:Fields starts with~, "", Code!GetSum())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.