Update row numbering of the header and footer rows in T-SQL - sql-server-2016

Can anyone please let me know about any logic that I can use to update the row numbers of the header and footer rows in such a way that the header always has the min row number of a specific group and the footer always has the max row number of a the same group.
In this example attached, the first header and footer belong to the first group and so on. Can this be done by just using a self join ?
Thank you
enter image description here

Related

How to group a text row in multiple data rows in Microsoft Report Builder

Basically I'd like to from this :
What I have
To this :
What I Want
Case in Orange are data that I pick up with an sql request while "This e-learning phase..." is just a plain text.
Does anybody knows how to do that ?
You could add a Parent Row Group and Group by the Information field.
Unfortunately, this would place the Information on the Left side of the table. Fortunately, there is a Layout Direction property for the table that can be switched from LTR to RTL so that the table is created from Right to Left instead of the default Left to Right.
This way the grouped information field on the right would only have one cell while there may be multiple Activities.
I'm not sure you'll be able to do this exactly how you want. This is because you cannot add rowgroup columns after non-grouped columns.
The only way you could get close is to not show the text if it's not the first row in the dataset (or rowgroup if the report is grouped somewhere)
You could use something like this in the Value expression.
=IIF(
ROWNUMBER("myDataSet_Namehere") =1,
"This e-learning phase must be completed before the start of the classroom part indicated below.",
Nothing
)
You could use a similar check to then set the vertical alignment property.
It looks like this...
The other option would be to move the test to the top of the table on it's own row in above the column headers, it would probably look neater..
Or you can wait for somebody else to come up with a better solution :)

How can I determine whether a table row immediately follows a page break

Given a Word table which spans several pages, how can my code determine that a table row is the first following an automatic page break? Note that table rows are of different heights thus a solution of the form "every 13th row is the first row on a new page" won't work.
The point of this would be to add extra text in the first cell at the top of every new page.
Use wdActiveEndPageNumber for that table row. Be sure that row is as big as it's going to get before checking the page number.
n = word.ActiveDocument.Tables(a).rows(b).Range.Information(wdActiveEndPageNumber)
If the table is sufficiently large that it splits over several pages then you compare the page number of consecutive rows until the page number changes. There are no pagebreaks to speak of.

How to avoid adding a new row to the first row of subtotaled ranges to protect Subtotal formula

I have a Excel sheet, which includes many groups and subgroups. Each subgroup has their own subtotal. And as long as I can't know how many lines users will require for the subgroups, I only left 3 rows blank for each subgroup and created a button which triggers Automatically Copy and Insert Copied Row macro.
Now I need to avoid users to trigger the button while they are on the First and the Last row of any subgroup. (If you copy and insert first row, subtotal formula doesn't recognise the new added line because it will be out of the range and Last row has another specific formulas which I don't want users to copy above)
I've been searching SO and the other Excel blogs for a long time but because of my list is very dynamic and have many different subtotals none of them was suitable to my case.
How can I define all of the first and last rows of my different subtotal ranges (and maybe their Title's rows) to avoid them being copied and then inserted above?
I can imagine 2 ways to do this. When the "New Row" button is pressed check if the current row is a headline/subheadline whatever …
by checking its format (eg specific background color etc).
If Not Worksheets("Sheet1").Range("A" & iRow).Interior.Color = 15004911 Then
'copy that row
End If
or by using an extra helper column that specifies the rows as header rows or non copyable rows. If you don't want the helper column to be seen you can hide it.
If Not Worksheets("Sheet1").Range("X" & iRow).Value = "Header" Then
'copy that row
End If
'where X is the helper column
And if it is a headline row then deny the copy process.
One way that doesn't involve programming have your sum range extend into rows that won't change. So you could start the subtotal in the header row (assuming there is no content in the relevant cell in that row). Another way is to have a hidden row at the top and bottom of each sum range and that is included in the sum range. So you would sum rows 10 to 14, but 10 and 14 would be hidden (and empty) and the user would just get shown rows 11, 12 and 13. Adding a new row would push the hidden rows down and extend the subtotal.
Another way is to use the indirect function.
Say your formula was
=SUBTOTAL(9,H7:H10)
If you use indirect for the lower bound, it will always refer to the cell immediately above, regardless of how many rows are added in between.
=SUBTOTAL(9,H7:INDIRECT("H"&ROW()-1))
And taking it one step further, use the upper title row as the anchor to always add up the gap between the title and the subtotal.
=SUBTOTAL(9,INDIRECT("H"&ROW(H6)+1):INDIRECT("H"&ROW()-1))

How to page break after specific row(Suppose 25 rows) in rdlc reporting

How to page break after Specific rows (like 15 rows) in rdlc reporting.
It's so easy.Suppose My reports looks like
Enable advance mode
Add a group for page break
Define the number of rows what do you want in the group expression(In this case i want 15 rows)
Delete group column if you not need
Delete Expression from Group details
Select Group Properties and set page break attribute breakLocation as End,Disables as false and RestPageNumber as fasle.
Select Group Details Properties and Set Disable=true
Now here's the report with page break after specific row
If You want to keep Table Header in every page than click here
You can add Row Group to your Tablix. Then in row group properties select Page Break section and set "Between each instance of a group".
What I did was create another property on your object called lineBreak or something.
when loading the objects make sure every 25 has the same number and increment by 1.
then in table put a group over the details, grouping on lineBreak. then add an extra line inside that group, then every 25th row should be a blank line.
Maybe you can use a rectangle with pagebreak, the rectangle is able to define a fixed heigth

How t add new rows atomatically, on scrolling the table view

I want to make an application in which I need a functionality of automatic addition on new rows to the table view. say at first the table view has 5 rows in it, after that when I scroll the table then more 5 rows should be added to the end of the table.
please help me!!!!
Hey!! You can try the idea as implemented on following post
http://iphoneappmonster.blogspot.com/2011/04/insert-rows-to-table-view-on-click-of.html
The way you would do this is to implement tableView:willDisplayCell:forRowAtIndexPath in your UITableViewDelegate, and watch for the last row being displayed (using the indexPath argument).
When the last row is about to be displayed, set a flag and call -reloadData on your UITableView. This will force the table view's recalculation, and call your datasource where you should see the flag and add (say) 5 rows to the previous total number of rows (and also clear the flag).
Now, the row that will display will no longer be the last row (it will have 5 rows below it) and presto! Infinitely-scrolling table view.
Keeping track of the total number of rows (and their content) is left as an exercise for the reader.