I have an SSRS report that pulls data similar to the one in the below table
incident_type zone seconds data_category data_type
Alarm East 30 A 1
Alarm East 90 A 2
Alarm East 120 B 1
Alarm East 180 C 1
Alarm West 30 A 1
Alarm West 90 A 2
Alarm West 120 B 1
Alarm West 180 C 1
Warning East 30 A 1
Warning East 90 A 2
Warning East 120 B 1
Warning East 180 C 1
Warning West 30 A 1
Warning West 90 A 2
Warning West 120 B 1
Warning West 180 C 1
What I want to do is display it like so:
Alarm East West
A 1 30 30
A 2 90 90
B 1 120 120
C 1 180 180
Warning East West
A 1 30 30
A 2 90 90
B 1 120 120
C 1 180 180
So, I set up my Tablix with the following groups
As you can see I have the data grouped in a way that breaks the data up correctly. However, the resulting tables look like this
Alarm East West
A 1 30 30
A 2 90 90
B 1 120 120
C 1 180 180
Alarm East West
A 1 30 30
A 2 90 90
B 1 120 120
C 1 180 180
As you can see, "Alarm" is repeated for the header. How can I get the value for [incident_type] to be the correct value in relation to the group?
It seems incident_type group is not set to be a header group.
Delete incident_type group and right click data_category group, select Add Group / Parent Group.... A window will pop up, set Add group header and select incident_type field.
After that, a new column will be added to the beginning of your tablix, delete that column and the required rows to leave this:
Merge the first two cells in the first row for the incident_type and you will get the desired output.
Let me know if this helps.
Related
I am trying to write a MySQL select statement which will use table1 and table2 to generate a table3.
table1
id
Month
Year
Name
Length
Breath
1
January
2002
Square
5
2
2
February
2003
Circle
6
3
3
March
2004
Cylinder
7
4
4
April
2005
Cube
8
5
5
May
2006
Quadilateral
9
6
table2
id
Month
Year
Name
Frequency
Area
Volume
1
January
2002
Square
1
20
50
2
Febrauy
2003
Circle
2
25
55
3
March
2004
Cylinder
3
Null
60
4
April
2005
Cube
4
35
65
5
May
2006
Quadilateral
5
40
Null
table3 the generated table should be like this.
Name
Type
Month
Year
Length
Breath
Frequency
Volume/Area
Cum_Area
Cum_Volume
Area
Volume
Square
2d
January
2002
5
2
1
2.5
20
50
20
50
Circle
2d
February
2003
6
3
2
2.2
45
105
25
55
Cylinder
3d
March
2004
7
4
3
2
45
165
30
60
Cube
3d
April
2005
8
5
4
1.86
80
230
35
65
Quadilateral
4d
May
2006
9
6
5
1.75
120
230
40
70
In the statements I've tried whenever the cumulative column encounters the first null value, every row from then on is null.
Also, how do I write the type column? I'd like square and circle to be '2d'; cube and cylinder to be '3d' and Quadrilateral to be '4d'.
Table 1 and 2 have the Name, Month and Year column in common.
I don't finish to understand what is your logic or why you don't have ids on the second table. But assuming what you write, this is a SUGGESTION.
Update your question I'll glad to update my answer.
Assuming null means 0:
SELECT
table1.Name,
CASE table1.Name
WHEN Square THEN '2d'
WHEN Circle THEN '2d'
WHEN Cylinder THEN '3d'
WHEN Cube THEN '3d'
WHEN Quadilateral THEN '4d'
END as Type,
table1.Month,
table1.Year,
table1.Length,
table1.Breath,
table2.Frequency,
(IFNULL(table2.Volume,0) / IFNULL(table2.Area,0)) as 'Volume/Area',
//I don't understand what do you need in this field,
//I don't understand what do you need in this field,
table2.Area,
table2.Volume
FROM table1
JOIN table2
ON table1.Name = table2.Name AND table1.Month = table2.Month AND table1.Year = table2.Year
Good morning all. I am working in Business Objects and am building essentially a history table and am having an issue summarizing it. A sample of Data is below.
Region Ref# Level
East 1 0
East 1 1
East 1 2
East 2 0
West 3 0
West 3 1
What I want the output to be is below (Crosstable):
Level 0 1 2
East 1 - 1
West - 1 -
Fiddler Here: http://sqlfiddle.com/#!9/9579da/3
Given this table of products
CountryId Product Quantity
1 Apple 100
1 Banana 5000
2 Carrot 50000
3 Apple 500
4 Apple 250
6 Apple 6000
And this table of available money
CountryId Quantity Rate
1 4135 0.005
1 870.5 1
1 1000 1
2 7249.71 0.007
2 1788 0.01
2 10 1
2 352 10
3 1900 0.09
4 29877 0.005
5 7108 0.005
Where Rate represents an exchange rate for the country. Not shown in the money table are seller Ids.
So for the first product, There are 100 apples in country 1. The Pricing for those Apples would be 100 * (0.005) because there was 4135 available money units for the 0.005 rate, of which we only needed 100 for our apples.
Another example: There are 5000 bananas for country 1. The pricing of those Bananas would be 4135 * (0.005) + 865 * (1). There wasn't enough 4135 money units at rate 0.005 so it had to take 865 units from the next available rate which was 1.
I am trying to use this logic and join the money table onto the products table and have a Price column. I have no idea how to start because it is not a simple Join
i have two tables in my toll database in MySQL, namely traffic_shift_wise and traffic_day_wise. And the columns of these tables are as follows:
Table traffic_shift_wise
toll_id date shift car_single car_return car_total
1 2016-09-01 1 25 10 35
1 2016-09-01 2 50 25 75
1 2016-09-02 1 100 50 150
1 2016-09-02 2 200 100 300
traffic_day_wise
toll_id date car_single car_return car_total
1 2016-09-01 75 35 110
1 2016-09-02 300 150 450
There are two shifts in day for a specific toll, here you can see that i have to take data from the traffic_shift_wise to traffic_day_wise, automatically just after insert in traffic_shift_wise.
So, please help me out with this. What should i use, triggers.. ?
I am quite new to Matlab, but I have some experience with other programming languages. I have a very large table imported from MySQL in Matlab. It is given as cell array that looks something like this:
date key sales weight name
12/11 101 1200 20 blue
12/11 178 1200 70 purple
13/11 209 1300 15 purple
12/11 101 1200 10 blue
14/11 678 1200 10 yellow
12/11 340 1500 30 green
17/11 178 1900 50 purple
And I want the output to be this:
key sales weight name
101 2400 30 blue
178 3100 120 purple
209 1300 15 purple
678 1200 10 yellow
340 1500 30 green
So I would like to combine the rows which have the same number in the column 'key'. Meanwhile I would like to sum the column 'sales' and 'weight' and keep the column 'name' (each 'key' has the same 'name', but each 'name' can have multiple 'keys')
I know this is possible with a for loop, but as I am having to manipulate a lot of tables in similar but different ways this is computational intensive.
I have read in similar problems this can be solved using accumarray, but can this be done with accumarray with a sub as cell array? And how would that look like?
Here is one method using accumarray, however it might be worth your while to consider the new table data structure instead of a cell matrix (I'm sure you can easily convert to it)
T = { 101 1200 20 'blue'
178 1200 70 'purple'
209 1300 15 'purple'
101 1200 10 'blue'
678 1200 10 'yellow'
340 1500 30 'green'
178 1900 50 'purple'};
[u, ind, x] = unique([T{:,1}])
key = T(ind,1)
sales = accumarray(x', [T{:,2}])
weight = accumarray(x', [T{:,3}])
name = T(ind,4)
[key, num2cell(sales), num2cell(weight), name]
x={ '12/11' 101 1200 20 'blue'
'12/11' 178 1200 70 'purple'
'13/11' 209 1300 15 'purple'
'12/11' 101 1200 10 'blue'
'14/11' 678 1200 10 'yellow'
'12/11' 340 1500 30 'green'
'17/11' 178 1900 50 'purple'};
[~,b,c]=unique([x{:,2}]);
y=[x(b,2),...
num2cell(sparse(1,c,[x{:,3}]))',...
num2cell(sparse(1,c,[x{:,4}]))',...
x(b,[5])];
unique is used to get the indices of duplicate keys. sparse is used to get the sum.