I have an SSRS tablix similar to this:
+----------+-----------+--------+--------+
| Total | RowGroup | Group1 | Group2 |
+----------+-----------+--------+--------+
| Perdiod1 | RowGroup1 | Value | Value |
| | RowGroup2 | Value | Value |
| Perdiod2 | RowGroup1 | Value | Value |
| | RowGroup2 | Value | Value |
| Perdiod3 | RowGroup1 | Value | Value |
| | RowGroup2 | Value | Value |
+----------+-----------+--------+--------+
Now, for each period, I want to calculate the count in each group. When I do:
Count(TableValue.Value, "Perdiod")
I get the total for the period (for both column groups). When I do
Count(TableValue.Value, "ColumnGroup")
I get the total for all periods. So really, what I need to do is something like this:
Count(TableValue.Value, "TablixRow", "TablixColumn")
which obviously doesn't exist.
So 'Value' should be a total count for a group within a Period (therefore, in the example given above, Value would be repeated twice in each Period (once for each RowGroup))
Is there a way to display the count of all the values within a specified column and row group in an SSRS's tablix?
You'd just need to add the aggregate expression to the matrix detail field without a specified scope, e.g. something like:
=Count(Fields!Value.Value)
Since you don't supply a scope, the aggregate will be calculated in its current scope, which for those value fields will be the particular group/period combination.
Edit after comment/update
Hmm... I'm trying to think of an easy way to do this, but coming up empty handed... I mucked around and could get any combination except the one you want.
Basically you're looking for something like:
=Count(Fields!Value.Value, "ParentRowGroup", "CurrentColumnGroup")
and I can't think of an effective way to do this.
Honestly (and it wouldn't be the first time for SSRS) the path of least resistance here is to add the period count you want to display as an extra column to your DataSet when you generate it, then just display this value unaggregated in the detail of the Matrix.
Annoying, but if you can control the DataSet it's a trivial solution to what is a difficult problem at the report level.
=CountRows()
=CountRows("GroupByInitial")
=CountRows("GroupByInitial",Recursive)
Related
I am new to SSRS and need help in completing this.
I have a SSRS report which has 2 different datasets Dataset 1 & Dataset 2. In Dataset 2 I have to use a calculation in one of the rows, which requires values from Dataset 2 and Dataset 1. Please see the image attached for the layout of the report and for other details. I would request your help in achieving the orange highlighted fields.
It is generally better to perform these calculations in the query if possible, but it is not impossible to include items from datasets other than the specified dataset for a tablix.
Depending on exactly how your datasets are set up, you may be able to use the Lookup function. This assumes you have a one-to-one relationship between the datasets. You can also sort of trick the function into working for datasets that don't have an explicit one-to-one relationship.
It's a little hard to tell your dataset structure from the information provided, I have a feeling your screenshot doesn't accurately depict your structure. Assuming your datasets are structured something more like this:
+------------------------------------+
| Category | Date | Value |
+------------------------------------+
| Gross Revenue | 2017-08-01 | GR8 |
| Gross Revenue | 2017-09-01 | GR9 |
| Gross Revenue | 2017-10-01 | GR10 |
| Profit | 2017-08-01 | P8 |
| Profit | 2017-09-01 | P9 |
| Profit | 2017-10-01 | P10 |
+------------------------------------+
and similar for Dataset 2, you should be able to use something like this to access the value from the other dataset:
=Lookup(Fields!Date.Value & "Cash Flow Rate", Fields!Date.Value & Fields!Category.Value, Fields!Value.Value, "Dataset2")
in SSRS each tablix object can only have one dataset. what you want to do is not possible using two different datasets. i'll suggest to do all calculations at query level in your dataset2.
In MySQL is there a way we can order the results in order of set of rules also used for filtering the results?
E.g. if we have a name field and input from the user then I would like to filter and sort the records as following
If we match the input against the name field
Exact Match
1st keyword of input exact match for name
2nd keyword of input exact match for name
Name starts with 1st keyword
Name starts with 2nd keyword
I would like to filter the results based on the above mentioned cases and order them in above listed sequence.
Input : two three
Data :
| one |
| two |
| three |
| one two three |
| one three two |
| three one two |
| two three one |
Output :
| two |
| three |
| two three one |
| three one two |
Full Text Search might a possible solution but from my past experience it does not always give an expected relevancy value to exactly order in the above mentioned manner.
I'm trying to access a field being called from the parent query within a nested one and here is my table
TABLE: reminders.
Columns: id:PK, rid:VARCHAR, title:VARCHAR, remind:Integer, start_day:DATE
SELECT id, remind, rid, title
FROM reminders
WHERE DATEDIFF(start_day, NOW()) <= (SELECT LEAST(3, remind))
Basically the second "remind" column in the LEAST() command is suppossed to reference the first "remind" column value for every row being spanned but for reasons that I can't just imagine i keep getting unexpected returns.
EDIT
In response to Sir Gordons that i provide more detailed info, I will try my best but I really do not know how to present table data here, but i'll try.
So basically i'm trying to SELECT all items from the reminders table WHERE the DIFFERENCE between the SET DAY (start_day) and TODAY doesn't exceed one of TWO values, those are either 3 or the value set in the remind column of the current row. Basically if the value set there is less than 3 then it should be used instead, but if it exceeds 3, 3 should be chosen. Here's a visual of the table.
+---+-----------------+--------------------+-----------------+-------------+
|id | rid | title | start_day | remind |
+---|-----------------|--------------------|-----------------|-------------|
|1 | ER456GH | This is real deep | 2014-01-01 | 10 |
|2 | OUBYV90 | This is also deep | 2014-01-13 | 10 |
|3 | UI90POL | This is deeper | 2014-01-13 | 60 |
|4 | TWEET90 | This is just deep | 2014-01-14 | 0 |
+---+-----------------+--------------------+-----------------+-------------+
So in editing this I realized that there was a false table entry under remind on the 4th entry that was causing it to pull false (i.e where remind = 0). Sigh. Some serious short sight on my part/lack of sleep I guess. The query does work . Thanks again.
You don't need a subquery here. Does this work?
SELECT id, remind, rid, title
FROM reminders
WHERE DATEDIFF(start_day, NOW()) <= LEAST(3, remind);
I have a matrix report in SSRS 2008 displaying information about a Company and the total points earned by each company for a selected Quarter.
Example
Company | Current | Previous | Diff |
--------------------------------------
| Q3 2008 | Q2 2008 | |
--------------------------------------
Comp 1 | 2000 | 1500 | 500 |
--------------------------------------
Comp 2 | 1200 | 1400 | -200 |
--------------------------------------
In my SSRS report I have a RowGroup based on my Company field from the data set ([Company]).
And I have a ColumnGroup based on my Quarter field from the data set. Sorting in the group is reversed because I want to start with the latest quarter.
I have parameter for selecting companies and 2 parameters for selecting quarters (QuarterCurrent and QuarterPrevious).
As a side effect if I select 2 quarters that are not consequent I get more than 2 columns which is something that I do not like.
But then I thought that if I could hide the columns in the middle and display on the First (QuarterPrevious) and the Last (QuarterCurrent) I will be able to compare any quarter to any other quarter.
My question is about hiding the columns in the "middle" of the matrix. I am trying to
achieve something like this:
Company | Current | *(HIDDEN)* | Previous | Diff |
----------------------------------------------------
| Q3 2008 | *Q2 2008* | Q1 2008 | |
----------------------------------------------------
Comp 1 | 2000 | *1500* | 1300 | 700 |
----------------------------------------------------
Comp 2 | 1200 | *1400* | 1250 | -50 |
----------------------------------------------------
So in the end I will have only the Current and the Previous columns visible.
I tried the following approaches:
Setting the Column Visibility property to:
=IIF(StrComp(Fields!Quarter.Value,First(Fields!Quarter.Value))=0 OR StrComp(Fields!Quarter.Value,Last(Fields!Quarter.Value))=0,False,True)
In my understanding this should set the property Hide to False to each column that is equal to the First and the Last values in the sequence, and to True to all the others. However it does not happen like this, but all columns were hidden.
I tried setting the same expression to the Visibility property in Group Properties. Still has the same effect - all columns were hiding.
Edit : format code
Instead of two parameters for your quarter selection, have you tried a multi-select dropdown parameter ?
I solved the issue in the following way:
Instead of using parameter with range (From and To) I used a parameter with two values and my queries is not BETWEEN From and To, but rather IN [From, To]. The values of From and To can be any 2 quarters (they can even be switched - From does not have to be before To).
Various documents define row as being synonymous with record. Unfortunately, a record can be a list or a single item. All the same, a row usually contains more than one item but is sometimes called "a single entry".
A field can be a container (for example, in html), which could be considered a place to input one item, or it could be considered a place where many items are entered (albeit on different occasions, sometimes).
It sure would be nice if someone could put it in simple terms. For example, a row is the result of a single-item, single-field entry via an insert statement. A field represents all rows and intersects a column.
Can anybody provide a clear answer because google just isn't cutting it. Thank you.
Edit:
In excel it sure is cut-and-dry. Column is all horizontal. Row is all vertical. Cell is a row-column pair; a single entry. Even though relational database languages are like working with multiple spreadsheets (tables), the column, row, cell approach seems to make the most sense.
I am looking at various different explanations that don't seem to agree with one another in the answers. Can we operationally define the terms for the tutorial I am presently working on, which is not clear? Link: http://zetcode.com/databases/sqlitetutorial/introduction/#about
If this is a table...
O--O-------------O-------------O
|ID| my_col_1 | my_col_2 |
O--O-------------O-------------O
|0 | fskdjfh | jfkhgdkfj |
|1 | NULL | hfkjsdh |
|2 | jfkdhsdkjh | NULL |
|3 | fdfhkjh | NULL |
|4 | NULL | NULL |
O--O-------------O-------------O
This is a row...
|0 | fskdjfh | jfkhgdkfj |
And this is a field...
| jfkhgdkfj |
Hows that?
Imagine you have to describe many aspect of the same thing. You have to choose which aspects you want to take care of: these are the columns of your table. For each of the column you can choose the data type to represent (numeric, String, ...). The column could be also a composite data type (ex: date) or a reference to another object.
The description of an object consists in all the values contained in the columns relative to that object: this is the row/record (the two terms have the same meaning in ER databases).
The field is the value assumed by a column--let's say that it is a cell in a table. It is part of the row, but it may have no sense outside the context provided by the row and the columns.
Maybe the confusion is due to the fact that to simplify the notation, the term field is used as the term column. When you see a query like "select * from foo where somefield=something" it means that you select the rows in which the field relative to the column "somefield", assumes the value "something".
This definition is ok also with HTML fields. A field of a form is the place where you enter the value the column will have in your case, that means, in the row that represents you.
One row/record, one column/field:
+---+
| x |
+---+
One row/record, three columns/fields:
+---+---+---+
| x | y | z |
+---+---+---+
Three rows/records, one column/field:
+----+
| x1 |
+----+
| x2 |
+----+
| x3 |
+----+
Three rows/records, three columns/fields:
+----+----+----+
| x1 | y1 | z1 |
+----+----+----+
| x2 | y2 | z2 |
+----+----+----+
| x3 | y3 | z3 |
+----+----+----+
fields or columns are defined with the table, and are the part of table structure, they hold information vertically. they describe the records or rows in the table.
Example: name, age, salary etc.
Rows or records are the real data that is stored in the table, these records are the actual information. one horizontal row represent one record.
Example: 'John', 23, 23000.00