Using lookup in SSRS - reporting-services

I have one dataset and I am trying to pick out certain rows from that dataset to populate my ssrs report. But I am having issues using the lookup function, i feel like i am using it right.
Function:
=LookUp(2,FieldsAccount_Range_Ind.Value,FieldsSNumberPlans.Value,”DataSet1”)
I need to find the second and third row of the data below
Account_Range_Ind SNumberPlans SAvgValuePlans INumberPlans IAvgValuePlans YNumberPlans YAvgValuePlans
1 1 121920.900000 1 69524.125000 0 0.000000
2 0 0.000000 1 260561.785000 0 0.000000
3 0 3017612.690000 0 0.000000 0 0.000000
Not sure what i am missing here, any help would be appreciated

Related

select non zero columns in mysql

I have a scenario where I need to display only non zero columns
id C1 C2 C3 C4
1 0 1 0 2
2 0 1 0 5
3 0 9 0 3
i want the output as below
id C2 C4
1 1 2
2 1 5
3 9 3
An SQL query always results in before-known columns. So you cannot do what you want to do in pure SQL. (And not being able to do something with SQL only is often a sign of a poor database design. Sometimes however it's that SQL is about how to get data, not how to display it.)
What you can do is get the columns' sums in one query, then build a new query dynamically (manually or within an app with Java, PHP or whatever programming language is used) that only selects the non-zero columns.

Grouping in SSRS?

i am new to the SSRS and Have data as below
RCnt Jobnumber NJCT JD pmt flag cnt1 cnt2
2 001008 0 PRESSURE SEAL PSI Y 0 0 2
2 001008 0 PRESSURE SEAL PSI Y 0 0 10
2 001008 0 PRESSURE SEAL PSI Y 0 0 1
1 001009 0 Single Sheet Duplex Legal PSI Y 0 0 1
1 001009 0 Single Sheet Duplex Legal PSI Y 0 0 4
6 001010 0 Single Sheet Duplex Legal PSI Y 0 0 6
5 001011 0 Single Sheet Duplex Legal PSI Y 0 0 5
5 001011 0 Single Sheet Duplex Legal PSI Y 0 0 3
13 001012 13 Single Sheet Duplex Legal PSI Y 0 13 0
13 001012 17 Single Sheet Duplex Legal PSI Y 0 17 0
13 001012 8 Single Sheet Duplex Legal PSI Y 0 8 0
And i want to display it as below ,
jobNumber NJCT JD cnt2 Rcnt
001008 0 PRESSURE SEAL 13 2
001009 0 Single Sheet Duplex Legal 5 1
001010 0 Single Sheet Duplex Legal 6 6
001011 0 Single Sheet Duplex Legal 8 5
001012 38 Single Sheet Duplex Legal 0 13
TOTAL 38 32 27
I know this grouping can be done at the server level in query but i don't have access to query and have to format this data as below in report using SSRS may be this is simple grouping i don't know when i googled about grouping it given me column level and row level grouping which left me very confused so any help related to this will be very helpful.Any links are also welcome to get grouping like this in SSRS report.
You have the following data in your Dataset:
Drag a table into the report and set its Dataset in the properties. Right click on the left of the table with the three lines and click Add Group -> Parent Group.
Group on the Jobnumber field, and check Include group header:
It will look like this:
Right click on the first column and choose Delete Columns.
Right click on the detail row and choose Delete Rows:
Click OK when prompted with Delete rows and associated groups?
Finally we need a table footer row - click on the bottom row and click Insert Row -> Outside Group - Below:
It should look like this:
Now add your data! Add new columns as required. When adding numeric data to these group and header fields, it will aggregate as a Sum by default:
Now the table is basically looking like the requirements; just format to taste:
Also, some links as requested:
Books Online, Adding Grouping and Totals (Reporting Services).
SQL Server Central, Tablix Tutorial.
These should be a good intro and are part of larger series of articles.

Does storing ASCII files as a BLOB field in MySQL or Oracle offer a reduction in storage requirements?

I have several thousand small ASCII files containing 3D cartesian coordinates for atoms in molecules (among other information) that I need to store somewhere.
A simple calculation told me that we will require several terrabytes of space, which may be reduced to several gigabytes at most, but is not manageable under current infrastructural constraints. Somebody told me some people have stored similar numbers of files (of the same format, but sometimes bzipped) in MySQL and Oracle as a BLOB field. My question is, does storing such files as BLOB offer some form of reduction in storage requirements? If yes, how much of a reduction can I expect?
This is example text from an ASCII file that needs to be stored:
#<TRIPOS>MOLECULE
****
5 4 1 1 0
SMALL
GAST_HUCK
#<TRIPOS>ATOM
1 C1 -9.7504 2.6683 0.0002 C.3 1 <1> -0.0776
2 H1 -8.6504 2.6685 0.0010 H 1 <1> 0.0194
3 H2 -10.1163 2.1494 -0.8981 H 1 <1> 0.0194
4 H3 -10.1173 3.7053 -0.0004 H 1 <1> 0.0194
5 H4 -10.1176 2.1500 0.8982 H 1 <1> 0.0194
#<TRIPOS>BOND
1 1 2 1
2 1 3 1
3 1 4 1
4 1 5 1
#<TRIPOS>SUBSTRUCTURE
1 **** 1 TEMP 0 **** **** 0 ROOT
#<TRIPOS>NORMAL
#<TRIPOS>FF_PBC
FORCE_FIELD_SETUP_FEATURE Force Field Setup information
v1.0 0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 NONE 0 0 0 0 1 0 0 0 0 0 0 0 0
Storing data in a BLOB column offers no form of reduction in storage requirements. The storage requirements for BLOB types are simple:
TINYBLOB L + 1 bytes, where L < 28
BLOB L + 2 bytes, where L < 216
MEDIUMBLOB L + 3 bytes, where L < 224
LONGBLOB L + 4 bytes, where L < 232
L represensts the length of the string data in bytes.
See Storage Requrements for further details.
If there is no need to search the contents of the molecule files in your database, you can reduce the storage requirements by compressing the data prior to inserting it or using the MySQL COMPRESS() function on insert.
I think that addressed your main question, and based on those figures and how many files you plan to store based on an average size, you can calculate how much storage space will be consumed by the BLOB type columns.

Simple Line Graph in SSRS

I'm having issues using the line chart control in SSRS. If I was in excel this would be easy but for some reason I can't wrap my head around how to do it in SSRS
I'm returning 5 rows of data from a database and need to chart 3 of the rows.
Name J F M A M J J A S
1 Requested 13 19 4 20 2 0 0 0 0
2 Completed 1 0 0 4 1 0 0 0 0
3 % Completed .7 0 0 0.2 0.5 0 0 0 0
4 Monthly Ba 12 19 4 16 1 0 0 0 0
5 YTD Backlog 12 31 35 51 52 52 52 52 52
The rows consist of the name and the value for that month.
I'm trying to display a chart for rows 1, 2, and 5 that would look like a normal line graph with each of the Months being on the horizontal column and the value being the data point.
However, when I start adding things to my chart I'm getting 36 different series, one for each Month for each series and nothing seems to be working right. It's also splitting into Group 1 and 2 at the bottom which makes no sense to me. I feel like I'm missing something simple, most likely a grouping of some kind.
EDIT:
I ended up taking Nathan's suggestion and added an unpivot on the table to rotate the data into an acceptable format for SSRS
Thanks
Can you alter the query that is returning the results for the dataset?
If so try changing it so that the dataset looks more like this:
monthnumber month Requested Completed YTD Backlog
1 J 13 1 12
2 F 19 0 31
3 M 4 0 35
4 A 20 4 51
etc.
You should be able to add "Requested", "Completed" and "YTD Backlog" as Values and "month" as a Category to produce the chart you want.
I added a "monthnumber" column, as you will probably want something like this so that you can set the category (month) sorting expression to this, otherwise they will appear in alphabetical order.

mySQL to retrieve records that repeat a value in order

I have a big table with 300,000 records. This table has a integer value called "velocity" and it`s value is from 0 to 100.
In the firsts records, the value is 0 and I want to remove. I want to remove from the query, the records where the velocity field repeats more than 10 times. For example:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 5 10 12 13 15 20 30 20 15 10 8 5 2 1 0 0 0 0 4 5 10 20...
[-------remove this-----------].......................................................................[---------] <- do not remove this
Thanks
The easiest way to do this is with a loop.
You can write a stored procedure that iterates through the records, or you might do it outside of the database. I'd do it like that if this needs to be done once. If this is a continuous process, it's better to make sure that the extra data is just not inserted into the database in the first place.
Anyway, if you insist on doing this in pure SQL, without stored procedures with loops, you can use a query like this:
set #groupnum=0;
select
GroupNum,
count(*) as RecsInGroup
from
(
select
t1.id as Id,
t1.velocity as velocity1,
t2.velocity as velocity2,
if(t1.velocity<>t2.velocity,#groupnum:=#groupnum+1,#groupnum) as GroupNum
from
VelocityTable as t1
join
VelocityTable as t2
on
t1.id=t2.id-1
) as groups
group by
GroupNum
having RecsInGroup>10
What happens here?
Step 1
The inner query just selects all records in your table, but splits the data in sequential groups.
So, using your example, it does this:
velocity : 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 5 10 12 13 15 20 30 20 15 10 8 5 2 1 0 0 0 0 4 5 10 20
Groupnum : 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 18 18 18 19 20 21 22
It does that by joining the table to itself, by linking subsequent records in the table. Every time the left and right velocity are different, the GroupNum is increased. Otherwise it's left unchanged.
Step 2
The result if the query is wrapped in an outer query, and grouped by GroupNum. Again, using your example it would result in this:
GroupNum,RecsInGroup
0,15 // !!
1,1
2,1
3,1
4,1
5,1
6,1
7,1
8,1
9,1
10,1
11,1
12,1
13,1
14,1
15,1
16,1
17,1
18,4 // !!
19,1
20,1
21,1
By Adding the having RecsInGroup>10 clause, the result becomes this:
GroupNum,RecsInGroup
0,15
Now, with this list of GroupNum's you can delete records.
Step 3
With the query above you have:
A list of all your records, with an added GroupNum column.
The list of GroupNum's that need to be removed.
Deleting the records should be easy at this point.
I'd just rip through the records sequentially, with a variable sized window that expands and contracts to comprehend identical values. Whenever the size is >= 10 when the value changes, delete the rows using the primary keys.
You can put BEGIN TRAN and COMMIT TRAN at the beginning and end of the DELETE statements to make things reasonably efficient.
thank you very much. I'm allmost there, but i tried it with a mySQL View as table source and it's not working (unkown table xxx). I can't use the whole table because it's have more than 19 millions records, I just need the record from a specific day, vehicle plate and city.