Page 1 of 1

Selective Grouping

Posted: Thu Oct 12, 2017 11:24 pm
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!

Re: Selective Grouping

Posted: Fri Oct 13, 2017 4:20 pm
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 2698 times
GroupCategoryByStartsWithCategoryName.mrt
(27.85 KiB) Downloaded 386 times
Thank you,
Edward

Re: Selective Grouping

Posted: Sat Oct 21, 2017 7:17 pm
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();
	}
}

Re: Selective Grouping

Posted: Mon Oct 23, 2017 3:43 am
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