Creating Subtotals Based on a Substring of a Field in SSRS

jnsimex used Ask the Experts™
Hi Experts,

I am using SSRS and I want to create a subtotal on based on the first 7 character of the AccountID field.

So the example attached, I would have a subtotal for the account 101-002-xx,  101-007-xx and 102-002-xx.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Never used SSRS, but bsing SUBSTR should get you what you need:

select SUBSTR(AccountID,1,7), sum(Amount) from <table> group by SUBSTR(AccountID1,7)

Open in new window


Ok I was able to add a subtotal to the group of accounts using the mid function but how do I add a total for only a certain account grouping?

In the screen shot below, I want to add a subtotal for all the accounts that begin with 102-xxx i.e. 10,488.57+10,245.71

Top Expert 2008

One idea is from your report's data set could you not created a calculated field based on the first 3 characters
Then add a grouping based on the calculated field that has it's own footer and place the subtotal calculation in that area

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial