1. Marcin Jurkowski
  2. PowerBuilder
  3. Tuesday, 21 May 2019 10:02 AM UTC

Hi,

I have a report as below.
I would like to automatically add number in each group header in No. X where X will be 1,2,3,4.etc...
Is this possible?

Regards,
Marcin

Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 22 May 2019 06:01 AM UTC
  2. PowerBuilder
  3. # Permalink

Try this:

create a hidden computed field (name it "cnt" for example) with this expression:

if (first( getrow() for group 1 ) = getrow(), 1, 0)

create another computed field to show your numbers with this expression:

cumulativeSum( cnt for all )

HTH,

René

Comment
  1. Marcin Jurkowski
  2. Wednesday, 22 May 2019 08:31 AM UTC
Thank you. That works perfectly fine!
  1. Helpful
There are no comments made yet.
David Peace (Powersoft) Accepted Answer Pending Moderation
  1. Tuesday, 21 May 2019 10:23 AM UTC
  2. PowerBuilder
  3. # 1

That's an interesting challenge. My first thought is to throw a page on the group change and use the page() function to give you the number. But that may not be appropriate.

I'll give it some more thought....

David

 

Comment
  1. David Peace (Powersoft)
  2. Tuesday, 21 May 2019 10:37 AM UTC
The only other way I can think that you can do this is with a database subquery linked to the primary query.



select groupvalue, rownum() from sourcetable group by groubvalue



This will return each groupvalue with a running count from 1 upwards, if you link this to your main query and use the value that should work.



What database are you using?



Cheers

David
  1. Helpful
  1. Marcin Jurkowski
  2. Tuesday, 21 May 2019 10:51 AM UTC
Thanks David.

We use MS SQL Server.

I'll try this way if it can't be done from PB.

Marcin

  1. Helpful
  1. David Peace (Powersoft)
  2. Tuesday, 21 May 2019 10:55 AM UTC
It should be pretty simple in MS SQL. Databases were designed to give you this stuff :-)
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.