SSRS histogram adding extra data. (chart) - reporting-services

I am trying to create a histogram to show frequency distribution using the following data in a table.
Values 25 35 37 37 38 38 40 40 41 44 46
For some reason an extra value of 45 is being added to my chart.
I have stripped this down to my query being something like this and have placed my dataset into a table to see the data and the correct data is being pulled.
SELECT values FROM table
So my problem is that I have 11 pieces of data but 12 are being displayed. What may be missing here?

This isn't using the histogram properties of the series but it should give you what you want.
I created a test dataset as follows
CREATE TABLE #t (score int)
INSERT INTO #t VALUES (25),(35),(37),(37),(38),(38),(40),(40),(41),(44),(46)
SELECT score, count(*) as Freq
FROM #t
GROUP BY Score
The obvious change is the frequency is calculated in the dataset query this time.
I then added a normal column chart, set the category groups to group on score and the values as [Sum(Freq)]
I then changed the Horizontal Axis properties as follows:
Axis Type = Scalar (Numbers/Dates)
Axis Range Interval = 1
Here's a link to the RDL, it contains your version and this new version. I've not added data labels etc. but hopefully it'll be helpful.
Histogram RDL

Related

How to take % value for Line graph for series Groups ?/How to plot graph by sql table?

Approach 1:How to take % value for Line graph for series Groups?
I am setting up a ssrs report like with x axis(Category Group) as Finished Week, QualityPercent( as Series groups-RFT%,REwork%,Scrap%) and Values as Sum of Quantity.
In the above graph the quatities are shown in percentages based upon weeks(the actual result whose plot values are given at left side of image). Respective tables structure:
But I am getting the chart like this
Here the y axis is not plotting well asper the category values, sometimes shoots upto 250%!! or 1400% !!! (this is embarrassing).
For the above graph i used expression as:
IIF(Sum(Fields!QTY.Value,"Chart11_SeriesGroup"),Sum(Fields!QTY.Value)/Sum(Fields!QTY.Value, "DataSet_Production"),0)
What i am missing? I even used #Percent. Kindly help me.
Approach 2: How to plot the ssrs graph using below result from sql query?
FinishedWeek QualityPercent QTY Percentage
1 Rework (%) 844 0.109724
1 RFT (%) 6811 0.885465
1 Scrap (%) 37 0.004810
2 Rework (%) 742 0.094618
2 RFT (%) 7096 0.904871
2 Scrap (%) 4 0.000510
After much work done with second approach, I wrote the separate query for the above table
asper the link:
Calculating percentage within a group
select t1.FinishedWeek,t1.QualityPercent,Sum(QTY) as QTY,Sum(QTY)/ t2.TOTAL_QTY as Percentage from #temp
AS t1
JOIN (
select FinishedWeek,Sum(QTY) as TOTAL_QTY from #temp
group by FinishedWeek
) AS t2
ON t1.FinishedWeek= t2.FinishedWeek
group by t1.FinishedWeek,QualityPercent,t2.TOTAL_QTY
From above query , took the Finished Week as Category, QTY as Values, and QualityPercent as Series Groups

Include a customized calculated field in MS Access Query

I am trying to execute a calculated field in MS Access.
Background
I have a single table including fields such as:
Name Week Hours_Charged
X 21-06 10
Y 21-06 20
X 21-06 30
Z 21-06 40
I am trying to create a new field in the query wherein it says Gap and contains the substraction from 40.
Additionally, it will should group according to the Same names. So the expected output would be:
Name Week Hours_Charged Gap
X 21-06 40 0
Y 21-06 20 -20
Z 21-06 40 0
Conditions: With the same name, there can be various dates and hours. However, the idea remains same.
Any leads on this would be appreciated.
Thanks in advance.
I have tried implementing through the design mode but was not successful.
I replied your table like this:
And got this query:
SQL code of this query (please note I've used different field names):
SELECT Table1.MyName, Table1.MyWeek, Sum(Table1.Hours_Charged) AS SumaDeHours_Charged, 40-[SumaDeHours_Charged] AS GAP
FROM Table1
GROUP BY Table1.MyName, Table1.MyWeek;
And design view of this query in MS Access (Please, note my Access is in spanish, so name of rows in design view are in spanish, not in english. If you want to know the meaning of something, you can ask me or use the SQL code:

Resize tables based on number of records in SSRS

I have two table having data like below:
SELECT *
FROM [dbo].[TestTable_1]
ID Value
----------
1 gjha
2 dc
3 d
4 ds
5 dg
6 hn
2nd table:
SELECT *
FROM [dbo].[TestTable_2]
Value
-----
jklsa
dfv
b
grt
trj
h
muik
rg
kuu
wd
gb
nm
wef
I'm fetching the data in SSRS report as below:
Question is:
How can I maintain the table size same? That is, if small table in SSRS report has 6 records (which is in this case),
the bigger one should adjust same size as small and the extra (/more) records that are coming in the large table should shift to right.
Here is the expected output from SSRS
Value Value
-------- -----------------
gjha jklsa |muik | wef
dc dfv |rg |
d b |kuu |
ds grt |wd |
dg trj |gb |
hn h |nm |
Note: The above details are just example, however, the number of records are really dynamic.
This is not a full answer as it's just what came to mind and is completely untested.
First thing is to search SO for ways to create a multi-column table, there are plenty of answers already so I won't explain in detail here. They usually involve adding RowNumber to each row which you can then use to calculate a matrix row and matrix column number, the column number can be used in a matrix as the column group. (e.g. if the row limit is 6 and the row number is 14, that will have a final row number of 2 (14 mod 6 = 2) and a column number of 3 as Floor(14/6)+1 = 3.
Next, create dataset that just gets the highest row count from each of your tables. Something like
DECLARE #a int
DECLARE #b int
SELECT #a = COUNT(*) FROM myTableA
SELECT #b = COUNT(*) FROM myTableA
SELECT CASE WHEN #a<=#b THEN #a ELSE #b END AS maxRows
Now you have the size of the smallest table, you can pass that as a parameter to the proc that gets the actual data from the two tables (this would be 6 in our example above)
I just answered a similar question here: https://stackoverflow.com/a/56350614/2033717
You can adapt this solution to your situation by replacing the 3 in the expressions with:
=Floor(Count(Fields!ColumnName.Value, "Dataset1") / Count(Fields!ColumnName.Value, "Dataset1"))
In other words, you're determining how many columns you need. And then grouping each row of the dataset into rows and columns of the matrix. This will work if you know the second table can be bigger than the first, but I'm not sure if it will work both ways without some additional conditions on the expressions.

FileMaker - Total SubSummary Values

I have a table with records each representing an appointment. I have the name of the contactthe appointment is with, and the date. In another table I have a field that contains how many appointments each contact is supposed to have during the day. There are 12 entries for each contact, because some are expected to have different numbers during different months.
I am able to call up the data for the appropriate contactfor the appropriate month. It looks great in the graph when I count up the number of entries for Contact A and put next to it the expected number of entries from the related table.
The problem I'm running into now is that I need to add up all of the expected appointments between all of the entities. So:
::ContactName:: ::appointments:: ::expected::
Contact A 12 10
Contact B 33 34
Contact C 18 27
Getting the roll up for the actual appointments is easy, a simple COUNT summary field in a subsubsummary section. But what of the expected? Because ContactA had 12 appointments that means that there will be 12 records for them, so putting a summary field for the expected column is would return 120 for all Contact A's. Instead, given the dataset above, I need the calculation to return 71. Does this issue make sense? Any help would be greatly appreciated.
If I am following this correctly, you need to divide the amount of expected appointments between the entries of the group, then total the result. So something like:
Sum ( Entities::Expected ) / GetSummary ( sCount ; EntityID )
(this would be easier if we knew the names of your tables and fields).
P.S. The term "entity" has a specific meaning in the context of a relational database. Consider using another term (e.g. "contacts").
Added:
Using your example data, you should see the following results in the above calculation field:
in the 1st group of 12 records: 10 / 12 = .8333333333333333
in the 2nd group of 33 records: 34 / 33 = 1.0303030303030303
in the 3rd group of 18 records: 27 / 18 = 1.5
When you sum all this up (using a summary field defined as Total of this calculation field), you should get 71 (or a number very near 71, due to rounding errors).
Note: in the above calculation, sCount is a summary field defined in the Appointments table as Count of [ any field that cannot be empty ], and EntityID is the field by which your records are sorted and grouped (and it must be a local field).

MS Access sum on groups, but not on details

I am trying to calculate a SUM in an MS Access report the following way:
Group1header - label
Group2header - value
Detail - example
Detail - example
Group2header - value
Detail - example
Group1footer [sum of Group2header value]
Somehow, when more detail rows appear, the sum in group1footer is incorrectly calculated (adds value for each detail).
I can not calculate the sums in the query, because the "value" is already a calculated in the query (a subquery would return to many rows):
(
(
(sl_ticketdetail.weight,0) * sl_ticketdetail.amount
- (
SELECT SUM(sl_invoicedetail.amount)
FROM sl_invoicedetail
WHERE ticketdetailid = sl_ticketdetail.ticketdetailid
)
/ 1000
)
* sl_ticketdetail.cost
)
/ 1000
Any idea on what could be going wrong?
Are you saying your are getting results like this:
Group 1a
Group 2a
Foo1 1
Foo2 1
foo3 2
Group 2a Sum 4
Group 2b
Foo1 3
Foo2 3
Group 2a Sum 6
Group 1a Sum 10
Group 1b
Group 2a
Foo1 4
Foo2 1
foo3 2
Group 2a Sum 7
Group 2b
Foo1 4
Foo2 3
Group 2a Sum 14
Group 1b Sum 21
This is the behaviour I would expect. I was able to do it by putting =Sum([value]) in an unbound field in each group footer (and even in the report footer).
I know 'works for me' isn't very helpful.
Have you labelled the detail's values fields (or the summary fields) with the same name as the data source? Sometime MS Access has weird behaviour if your fields have the same name as their bound data source (I tend to rename them slightly so I'm sure what I'm referring to in code).
Since you already have the Group2 sums pre-calculated in your query they will be repeated for each row of results and therefore cannot be used (as you found out) to calculate the Group 1 totals.
You have two solutions
1) pre-calculate the Group1 totals in your query as well and simply report them liek you do the Group2 totals
2) use code in the Group2 footer format/print events to capture the value and manually increment a running Group1 total
I would say 1) is the easiest - 2) is a little hairy and sometimes results in inaccurate totals if the users pages back and forth
You would have to have the record source of the main report to include the totals for Group 2. Then you would need a sub report with a different record source that is on the detail level.
I think your best bet, is to omit the totals in the query and just let the report do the totals on the details. Later, the user may want totals on the same date but a different grouping (yes, you could create another record source). This should also address if a user applies a filter on the report (You may or may not have given them this option.) on a field other than the grouping.