How to sum the value and move to the next sequential row in sql server ?
Kindly can some one help me on the below business scenario .
CountryCode is_holiday ? TicketsRaiseDay NofTickets TotalTickets 91 No Mon 10 10 91 No Tue 20 20 91 Yes Sat 10 NA (since it is holiday ) 91 No Mon 5 15 (Sat tickets +Monday Tickets ) Here totaltickets column is calculated or computed column or report column . Note : is_holiday column is the responsible to hold holiday detail so need not to bother about this field . It would be great if i can get either ssrs expression or sql code . Purpose is i need to display in reports as totaltickets field by doing cary forward tikckets count to the next immediate row and holiday field should be NA ..
CountryCode is_holiday ? TicketsRaiseDay NofTickets TotalTickets 91 No Mon 10 10 91 No Tue 20 20 91 Yes Sat 10 NA (since it is holiday ) 91 No Mon 5 15 (Sat tickets +Monday Tickets ) Here totaltickets column is calculated or computed column or report column . Note : is_holiday column is the responsible to hold holiday detail so need not to bother about this field . It would be great if i can get either ssrs expression or sql code . Purpose is i need to display in reports as totaltickets field by doing cary forward tikckets count to the next immediate row and holiday field should be NA ..
August 18th, 2015 2:37pm
Hi ,
Do you have any row number or Date column in the above data set ?
Free Windows Admin Tool Kit Click here and download it now
August 19th, 2015 2:13pm
Hi Franklin,
If I understand correctly, you want to set the TotalTickets to NA when the day is a holiday, then add it to the next sequential row TotalTickets. Otherwise, just display NofTickets as TotalTickets value in a SSRS report table.
If in this scenario, we can refer to the following SSRS expression to achieve your requirement:
=iif(Fields!is_holiday.Value="Yes","NA",Fields!NofTickets.Value+iif(previous(Fields!is_holiday.Value)="Yes",previous(Fields!NofTickets.Value),0))
Thanks,
Katherine Xiong
August 24th, 2015 3:26am