Selective Grouping

Stimulsoft Reports.WPF discussion
Post Reply
mpilz
Posts: 2
Joined: Thu Oct 12, 2017 10:59 pm

Selective Grouping

Post by mpilz »

Hi!

I would like to group the following table (simplified), but the grouping should only take place if the PostingCode starts with "HOTEL":

Code: Select all

Date||PostingCode||Amount
01.10.	HOTELVTI	 100
01.10.	HOTELVTN	  10
01.10.	BOX			-10
01.10.	TAX		 	5
02.10.	HOTELVTI    50
02.10.	TAX		   5
02.10.	HOTELVTN	 10
02.10.	MISC		  12
The outcome should be:

Code: Select all

Date||PostingCode||Amount
01.10.	HOTEL      110
01.10.	BOX        -10
01.10	 TAX          5
02.10.	HOTEL       60
02.10.	TAX          5
02.10.	MISC        12
Is there any way to achieve this using a GroupHeader Band?
Thanks for your help!
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Selective Grouping

Post by Edward »

Hi Mpilz,

Yes, that is possible. Please open the attached report in viewer.exe application where the Demo database is available.
GroupCategoryByStartsWith.PNG
GroupCategoryByStartsWith.PNG (49.34 KiB) Viewed 2368 times
GroupCategoryByStartsWithCategoryName.mrt
(27.85 KiB) Downloaded 331 times
Thank you,
Edward
mpilz
Posts: 2
Joined: Thu Oct 12, 2017 10:59 pm

Re: Selective Grouping

Post by mpilz »

Hi Edward!

Thank you very much for your reply!
The problem with your solution is, that also other postings get grouped, if they occur on the same date.

I found an other solution, even though it´s not very pretty. I added a random number to all PostingCodes which do not start with "HOTEL" in the report´s rendering event.

Code: Select all

Random suffix = new Random();

foreach (DataRow row in MyTable.DataTable.Rows)
{
	if (!row["PostingCode"].ToString().StartsWith("HOTEL"))
	{
		row["PostingCode"] += suffix.Next(100).ToString();
	}
}
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Selective Grouping

Post by Edward »

Hi Mpilz,

In that case your solution does make sense, thank you for the update, I did not noticed the date column initially.

Thank you,
Edward
Post Reply