August 7, 2008 at 5:08 pm
Hi,
I have many matrix in a report and each one have a Subtotal.
I need sum all SubTotals. How can I to do this?
thanks,
Marcelo.
August 7, 2008 at 9:05 pm
Sum of all individual items plus their sub-totals is always twice as large as the subtotals themselves. Sum everything and divide by 2.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 8, 2008 at 7:52 am
i need an example or a report to understand your problem. is this what trying to get?
[font="Courier New"] |jun |jul |aug |total
aaa | 10 | 20 | 15 | 45
bbb | 5 | 7 | 10 | 22
-----+----+----+----+-----
total| 15 | 27 | 25 | 67[/font]
August 8, 2008 at 8:16 am
OK. Per example:
first matrix
|jun |jul |aug |total
aaa | 10 | 20 | 15 | 45
bbb | 5 | 7 | 10 | 22
-----+----+----+----+-----
total| 15 | 27 | 25 | 67
second matrix
|jun |jul |aug |total
aaa | 20 | 30 | 45 | 95
bbb | 5 | 7 | 10 | 22
-----+----+----+----+-----
total| 25 | 37 | 55 | 117
i need to do this:
1 - total| 15 | 27 | 25 | 67
2 - total| 25 | 37 | 55 | 117
-------------------------------
3 - total 40| 64 | 80 | 184
do you understand?
August 8, 2008 at 8:39 am
are the two matrices coming from 2 datasets or 1 dataset? if it's a single dataset, then create another matrix with a single row grouping that equates to whatever distinguishes matrix 1 from matrix 2.
if it's 2 datasets, it will be much more difficult.
August 8, 2008 at 8:45 am
there is one dataset for each matrix.
August 8, 2008 at 9:28 am
marcelo (8/8/2008)
there is one dataset for each matrix.
Oy! Can the datasets be combined?
August 8, 2008 at 10:24 am
No, because my querys using MDX and differents hierarchys.
Any suggestion?
August 8, 2008 at 7:01 pm
marcelo (8/8/2008)
OK. Per example:first matrix
|jun |jul |aug |total
aaa | 10 | 20 | 15 | 45
bbb | 5 | 7 | 10 | 22
-----+----+----+----+-----
total| 15 | 27 | 25 | 67
second matrix
|jun |jul |aug |total
aaa | 20 | 30 | 45 | 95
bbb | 5 | 7 | 10 | 22
-----+----+----+----+-----
total| 25 | 37 | 55 | 117
i need to do this:
1 - total| 15 | 27 | 25 | 67
2 - total| 25 | 37 | 55 | 117
-------------------------------
3 - total 40| 64 | 80 | 184
do you understand?
Sure... like I said, divide the sum of the union of the two result sets, including the totals, by 2 and you're done.
The "proof"...
[font="Courier New"] |jun |jul |aug |total
+ aaa | 10 | 20 | 15 | 45 -- + bbb | 5 | 7 | 10 | 22 > Result set #1 including total
+ total| 15 | 27 | 25 | 67 --/
+ aaa | 20 | 30 | 45 | 95 -- + bbb | 5 | 7 | 10 | 22 > Result set #2 including total
+ total| 25 | 37 | 55 | 117 --/
-----+----+----+----+-----
SUM 80 128 160 368 --Unioned sum of everythin including totals
-----+----+----+----+-----
/2 40 64 80 184 --Divide by 2 to get final correct answer [/font]
The code...
SELECT SUM(Jun)/2 AS Jun, SUM(Jul)/2 AS Jul, SUM(Aug)/2 AS Aug, SUM(Total)/2 AS Total
FROM (--==== Derived table "d" creates sums for each result set
SELECT SUM(Jun) AS Jun, SUM(Jul) AS Jul, SUM(Aug) AS Aug, SUM(Jun+Jul+Aug) AS Total
FROM ResultSet1
UNION ALL
SELECT SUM(Jun) AS Jun, SUM(Jul) AS Jul, SUM(Aug) AS Aug, SUM(Jun+Jul+Aug) AS Total
FROM ResultSet2) d
--Jeff Moden
Change is inevitable... Change for the better is not.
August 10, 2008 at 11:19 am
marcelo (8/8/2008)
No, because my querys using MDX and differents hierarchys.Any suggestion?
no simple ones. as you've discovered, you can't access the intermediate summaries of a matrix. (in the example, you can't access the monthly subtotals).
you can combine multiple MDX queries by creating a linked server to the analysis server and then using openquery() to get the results. of course, you won't be able to use the MDX query designer in reporting services to edit the actual query.
your sole dataset's query would then become:
[font="Courier New"]select 1 as batch, ...columns... from openquery( SSAS, 'MDX query 1' )
union all
select 2 as batch, ...columns... from openquery( SSAS, 'MDX query 2' )[/font]
from there, your first two matrices would be filtered by [batch] and the summary matrix would be grouped on [batch] only.
August 18, 2008 at 8:34 am
Hi. I can't to do this.
Can you give me a pratice example using "union all" and "openquery" for MDX?
Can I to do this when my query use differents cubes?
thanks,
Marcelo.
August 18, 2008 at 7:10 pm
Sorry Marcello... a bit of ignorance on my part showing... didn't realize you were doing it in MDX and I know just about nothing about MDX. My appologies.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply