I have a report with a tablix that is grouped on a supplier group. I have a details group that contains a Sequence, Block and Product number. I need the report to sort based on the Sequence column (first column in the details group). My problem is that even with the sort applied at the dataset, and details group level I am getting a sort that goes 1,4,5,6,7,8,9,10,11,2,3 etc. I have 32 sequences. I would understand if the sort went 1,10,11 etc but it is jumping over 2 and 3. The field is defined as an integer so I can't figure it out. When I look at this in the query in the dataset the sorting is correct. I am at a loss. I have tried applying the sort at every level within the report and also not applying the sort at all. Anyone have any ideas?
Can you share which version of SSRS and also include an image of the report output, tablix, and row groups?
I would recommend you remove the ORDER BY from your SQL in the data set. In my experience, SSRS can sort this more efficiently in your tablix than SQL Server.
Also, I prefer to focus any sorting at the closest level of user visibility (I only think of sorting as useful for users). Therefore, I recommend you apply the sorting to the row group. Also, if the sequences you are using, they appear to be integers, ever convert to text, make sure you convert the field back to a number in your sort expression. I suggest you convert this to an integer even if you are certain that it is already an integer, at least for testing.
Related
This is my first question on StackOverflow so apologies if there is not enough appropriate information.
Rather than having four different tables that I try to position 'just so' so that they look like one table, I was hoping to have all of my data in one visible table and hide the rest.
To do this I was trying to use LookupSet/Lookup with Running Value (I need a cumulative figure for each fortnight from a start date).
I have used the following code which supplies me with figures in the table - however the figures seem to be nearly double what they actually are.
=Lookup(Fields!StartFortnightDate.Value, Fields!StartFortnightDate.Value,
Fields!RowIdentifier.Value, "KPI004")
Is it possible to use Lookup with RunningValue? It won't let me use ReportItems either its obviously only pulling from the first box and therefore is just repeating the first figure again and again.
Any help, guidance, or even a simple "it's not possible" would be appreciated.
Edited to add more information as suggested:
It's difficult to add example data without worrying about data protection etc.
Report design is currently:
ReportDesign
Each table has it's own dataset - I'm trying to get them all into one table.
Lets say the first dataset is number of cars sold in each fortnight.
The second dataset (table) is number of meetings held.
The third dataset is number of days weather was sunny/cloudy/rainy etc.
(This obviously isn't what the datasets are, but I'm trying to show that they don't actually relate to each other that much and therefore can't all be in the same script)
All datasets have a table of the fortnightly dates within that quarter, my hope was to get one table that showed the cumulative figures of each item even though they're not in the same dataset - the tables are all grouped by the StartOfFortnightDate.
The script =RunningValue(Fields!NumberOfFordCarsSold.Value, Count, Nothing) and similar works fine in the separate tables, however if I add a row to the top table and try to use RunningValue with Lookup it doesn't work.
When I used the script mentioned at the top (Lookup script) I get inflated figures (top row of this image) compared to the expected figures (bottom row of the image): IncorrectAndCorrectFigures
Apologies if this doesn't make sense, it's likely that my complete confusion in trying to find the answer is coming across in the question.
If the resulting datasets are all similar then why can you not combine them?
From the output they seem to be just Indicator & Date.
Add an extra column to indicate which set of data each row belongs to (Cars Meetings etc), this might help with grouping rows in the report.
I have an SQL query that gives me a data set with 3 columns:
Contract Code
Volume
MonthRegistered
I want to present this data grouped on rows by Contract_Code and columns by MonthRegistered:
I then want to calculate a Percentage difference between the months:
I will only ever in this case have 2 months worth of data - Each 1 year apart.
I am trying to express the percentage variation from one year to the next for each row of data.
I did this expression:
=(Fields!Volume.Value)/(Fields!Volume.Value)
but CLEARLY it was not right - and how it is not right is it is not addressing the columns independently.
I did format the TABLIX text box as a percentage so at least I figured that one out.
in this Technet article: Calculating Totals and Other Aggregates (Reporting Services) it states:You can also write your own expressions to calculate aggregate values for one scope relative to another scope. I couldn't find reference to how to address the separate scopes.
I would appreciate any pointers on this one please!
Sorry for posting my examples as JPG rather than actual text but I needed to hide some of the data...
This only works because you will only ever have two months worth of data to compare. You have to make sure that your SQL has already ordered by MonthRegistered. If you do not order in your query then SSRS's own sorting will be applied to determine which value is first and last.
=First(Fields!Volume.Value) / Last(Fields!Volume.Value)
Because you have performed the aggregation in SSRS you may have to wrap each statement in a SUM expressions.
It would be advisable to perform the aggregation in SQL where possible, if you only plan on showing it in this way.
A bit of a tricky question - I might just have to do it through VBA with a proper script, however if someone actually has a complicated answer, (let's be honest I don't think there's a super simple formula for this) I'm taker. I'd rather do as much as I can through formulas. I've attached a sample.
The data: I have data that relates to countries. In each country, you can have multiple sites. For each site, you may or not have different distributions. When those distributions meet a given criteria, I want to tally up that as a "break" & count how many by countries, sites, etc.
How it works: I'm using array formulas with sumproduct() for this. The nice thing is that you can easily add criteria, each criteria returns your 0/1 so when you multiply them it gives you the array you need to sum up to see how many breaks you have.
The problem: I am unable to format the formula so that I can account for each site being counted only once in the case where the same site has 2 different distribution types and both meet the break criteria. If both distributions meet the break criteria, I don't want to record that as 2 breaks, otherwise I may end up with more sites with breaks recorded than the number of sites. Part of the problem is how I account for the unicness of sites:
(tdata[siteid]>"")/COUNTIF(tdata[siteid],tdata[siteid] &"")
This is actually a bit of a hack, in the sense that as opposed to other formulas it doesn't return 0/1 but possibly fractions. They do add up correctly and do allow me to, say, count the number of sites correctly, but the array isn't formated as 0/1 therefore when multiplied with other 0/1 arrays it messes up the results....
I control the data, so I have some leeway. I work with tables (as can be seen) and VBA is already used. I could sort the source tables if that helps. Source data:
1 row = 1 distribution for 1 site on 1 month
The summary table per country I linked is based on those source data.
Any idea?
EDIT - Filtering for distribution is not really an option. I do already have an event-based filters for the source data, and I can already calculate rightly the indicator for filtered data by distributions. But I also need to display global data (which is currently not working). Also there are other indicators that need to be calculate which won't work if I filter the data (it's big dashboard).
EDIT2: In other words, I need to find some way to account for the fact that if the same criteria (break or not) is found in 2 sites with the same siteid but 2 different distributions, I want to count that as 1 break only. While keeping in mind that if one distribution has a break (and the other not), I still want to record it as 1 site with break in that country.
EDIT3: I've decided to make a new table, that summarizes the data for each site individually (each of which may have more than once distribution). Then I can calculate global stuff from that.
My take home message from this: I think that when you have many level of data (e.g. countries, sites, with some kind of a sub-level with distributions) in Excel formulas, it's difficult NOT to summarize the data in intermediate tables for the level of analysis at which you want to focus. E.g. in my case, I am interested in country-level analysis, which is 2 "levels" above the distribution level. This means that there will be "duplication" of data from a site-level perspective. You may be able to navigate around this, but I think by far the simpler solution is to suck it up and make an intermediate table. I does shorten significantly your formulas as well.
I don't mark this as a solution because it's not what I was looking for. Still open to better suggestions allowing to work only with formulas....
File: https://www.dropbox.com/sh/4ofctha6qhfgtqw/AAD0aPJXr__tononRTpKc1oka?dl=0
Maybe the following can help.
First, you filter the entries which don't meet the criteria regarding the distribution.
In a second step, you sort the table from A to Z based on the column siteid.
Then you add an extra column after the last on with the formula =C3<>C4, where column C contains the siteid entries. In that way all duplicates are denoted by a FALSE value in the helper column.
After that you filter the FALSE values in this column.
You then get unique site ids.
In case I got your question wrong, I would be glad about an update in order to try to help you.
Okay. two questions on interactive sorting:
1. How to sort on multiple columns without holding SHIFT key?(like this: http://lukehayler.com/2011/04/sorting-on-multiple-columns-in-ssrs/)
2. How do I cancel sorting? So, usually on most web, first click on sorting arrows icon sorts by ascending, second click sorts by descending, third click cancels sorting. With SSRS I only observe first two options. Is there a way to cancel column sorting?
1) Right now that is just how the report viewer works, as others have said you could write your own controll to view the reports but this may not be an option due to time or skill level constraints.
Other people have written their own custom report viewer controls however I have always stuck to the MS version so I havent got much experience with these, and I would suspect any good ones would be a paid solution.
2) I would love this option myself, again you cant reset the sorting in this way as SSRS does not keep a record of the initial 'unordered' state of the data.
The only options you really have here are to reload your data with its original parameters or as nathan pointed out include a column that contains the starting sort order, however users may not like this as it is adding data which is not really relevant to the report data.
1) There is no way to do this with the standard report viewer control
2) There is no way to "cancel" sorting. However assuming the data was sorted into some order originally then you could include a column on the report that represents the original sort order (if it's complex ordering then you could represent this with a sequence number). This would allow the user to sort on that column to return to the original order of the report.
I've written some very basic tools for grouping, pivoting, unioning and subtotaling datasets sourced from non DB sources (eg: CSV, OLTP systems). The "group by" methods sit at the core of most of these.
However i'm sure lot of work has been done in making efficient algorithms for grouping data... and i'm sure i'm not using them. And my Google-fu has completely failed to turn anything up.
Are there any good online sources or books describing the better methods to create grouped data?
Or should i just start looking at the MySQL source or something similar?
One very handy way to "group by" some field (or set of fields and expressions, but I'll use "field" for simplicity!-) is when you can arrange to walk over the results before grouping (RBG) in a sorted way -- you actually don't care about the sorting (save in the common case in which an ORDER BY is also there and just happens to be on the same field as the GROUP BY!-), but rather about the "side effect" property of ordering -- that all rows in RBG with the same value for the grouping field come right after each other, so you can accumulate until the grouping field changes, then emit/yield the results accumulated so far, and proceed to reinitialize the accumulators with the new row (the one with a different value of the grouping field) -- make sure to "just initialize the accumulators" at the very start, AND "just emit/yield accumulated results" at the very end, of course.
If this doesn't work, maybe you can hash the grouping field and use a hash table for the results being accumulated for that group -- at each row in RBG, hash the grouping field, check if it was already present as a key in the hash table, if not put it there with accumulators suitably initialized from the RBG row, else update the accumulators per the RBG row. You just emit everything at the end. The problem of course is you're taking up more memory until the end!-)
These are the two fundamental approaches. Would you like pseudocode for each, BTW?
You should check out OLAP databases. OLAP allows you to create a database of aggregates meant to be analyzed in a "slice and dice" fashion.
Aggregate measures such as counts, averages, mins, maxs, sums and stdev's can be quickly analyzed by any number of dimensions using an OLAP database.
See this introduction to OLAP on MSDN.
Give an example CSV file and type of result wanted and I might be able to rustle up a a solution in Python for you.
Python has the CSV module and list/generator comprehensions that can help with this sort of thing.
Paddy.