Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datawindow expression for rownumber 1

Status
Not open for further replies.

jbeetz1

Programmer
Nov 28, 2000
60
US
Is there a computed field I can create in a datawindow that will number the rows starting back at 1 for each group break.

Thanks
Jbeetz1
 
Hi,

Create Compute column and set values starting from 1. Use FindGroupChange function to get row num where group is changing. Reset counter and start from 1 again.

Do While ll_Counter <= ll_RowCount
ll_Counter = 1
ll_GroupChange = dw_control.FindGroupChange (ll_Counter,level)
ll_RowNum = 0
For ll_Ctr = ll_Counter To ll_GroupChange - 1
ll_RowNum ++
dw_control.object.compute_col [ll_Ctr] = ll_RowNum
Next
ll_Counter = ll_GroupChange
Loop

Cheers,
Abhijit.
 
Abhijit

Thanks for the feedback. I did it that way. I was looking for an easier way by just adding a computed field to the datawindow object that would calculate automatically without writing the code. It would be similar to using the getrow() function, but would need to start back at 1 for each group break.

Jbeetz1
 
To do this, just create a computed column with the value GetRow() - First(GetRow() for Group 1) + 1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top