hi we run 2014 enterprise. i've inherited a matrix within matrix report that i've anonymized and dumbed down big time in the attached ddl and mock up. the 3 data regions you see to the left of the mockup are actually tablix's inside a matrix that breaks on camp name and create date. there is a one to one between session id and the combo of camp name and create date.
currently, the inner tablix's are of a fixed size. so really the columns in one row of the select on matrixwithinmatrix map one to one with the inner tablix cells for "this break".
i'm faced with adding a true matrix (shown to the right of "i want to add this to the report". from what i remember, the scope of an inner matrix cant be different than the scope of the outer matrix. so i'd better not think about a different dataset. i'm thinking about concatenating the date, max count pairs into the single row currently extracted for any one session and somehow splitting it into the new tablix. i'd hate to redesign the current report's matrix within atrix approach. does the community have any ideas?
USE [research]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--drop table matrixwithinmatrix
CREATE TABLE [dbo].[matrixwithinmatrix](
[Id] [int] IDENTITY(1,1) NOT NULL,
SessionId int,
CampId Int,
CampName varchar(100),
CreateDate datetime2(7),
CamperCount_type1 int,
CamperFees_type1 decimal,
CamperCount_type2 int,
CamperFees_type2 decimal,
CounselorCount_type3 int,
CounselorSalaries_type3 decimal,
CounselorCount_type4 int,
CounselorSalaries_type4 decimal,
CONSTRAINT [PK_matrixwithinmatrix] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
insert matrixwithinmatrix
select 1,1,'Rolling Hills','1/1/2021',5,5000,10,10000,
2,1000,2,10001
union all
select 2,1,'Rolling Hills','2/1/2021',6,6000,11,11000,
3,1500,3,1501
union all
select 3,2,'no hills','3/1/2021',7,7000,12,12000,
4,2000,4,2001
union all
select 4,2,'no hills','4/1/2021',8,8000,13,13000,
5,2500,5,2501
select * from matrixwithinmatrix order by campname,createdate--<---think of this as the current report dataset
USE [research]
GO
--drop table matrixwithinmatrixboatschedule
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--drop table matrixwithinmatrix
CREATE TABLE [dbo].[matrixwithinmatrixboatschedule](
[Id] [int] IDENTITY(1,1) NOT NULL,
SessionId int,
starttime datetime2(7),
endtime datetime2(7),
maxcampers int,
CONSTRAINT [PK_matrixwithinmatrixboatschedule] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
insert matrixwithinmatrixboatschedule
select 1,'2021-01-02 10:15:00.000','2021-01-02 10:45:00.000',5
union all
select 1,'2021-01-02 11:15:00.000','2021-01-02 11:45:00.000',6
union all
select 1,'2021-01-03 11:15:00.000','2021-01-03 11:45:00.000',9
union all
select 2,'2021-01-02 10:15:00.000','2021-01-02 10:45:00.000',7
union all
select 2,'2021-01-02 11:15:00.000','2021-01-02 11:45:00.000',8
union all
select 3,'2021-01-02 10:15:00.000','2021-01-02 10:45:00.000',9
union all
select 3,'2021-01-02 11:15:00.000','2021-01-02 11:45:00.000',10
union all
select 4,'2021-01-02 10:15:00.000','2021-01-02 10:45:00.000',11
union all
select 4,'2021-01-02 11:15:00.000','2021-01-02 11:45:00.000',12
select * from matrixwithinmatrixboatschedule order by sessionid,starttime
select sessionid,cast(starttime as date) starttime,sum(maxcampers) maxcampers--<--think of this as the desired but probably not legal dataset
from matrixwithinmatrixboatschedule
group by sessionid,cast(starttime as date)
order by sessionid,starttime