combine and sum multiple groups - sql

I have been having trouble for a while figuring this out.I have managed to generate fields based on weeks.
Now I want something like this
In Crystal reports How can I achieve this?

i have faced the same case and i found 2 options to solve the same
1- from db level you can add new column to get week number in that year and then get the sum value according to week number.
2- from crystal report, you can set number of weeks in a running field and use mod to get the division remaining (week number mod 2), if it is equal to zero then you can get the sum or reset the sum parameter.
in the formula sum field:
{#DayName} = "Friday" AND {RptEmpMove;1.WeekNum} mod 2 = 0

Related

IIF statement is showing a 0 where I know there is a value

I have a dataset with values that I'm am trying to put into an SSRS report. Here is some example data:
Fund#
last week amount
YTD Total
1
$100
$1500
2
$0
$300
3
$500
$500
4
$0
$0
The first column in my SSRS report is a fixed list of fund names in the certain order that I want them to appear and I want to insert the amounts from the dataset into the row with the corresponding fund name and into the right column.
I tried to get the amount for Fund 1 from last week ($100) to appear in the report using the following expression:
=iif(Fields!fund_no.Value=1,fields!last_wk_amt.Value,0)
However, this is returning a 0 value but I know it should read 100. This seems pretty simple, but I just can't figure it out what I'm doing wrong.
Thanks for the help.
It sounds like your field is an aggregate of the dataset. The IIF statement works on a ROW basis. In your expression, it finds the first row (which is apparently not 1) and returns the evaluation.
I believe it would work correctly if you SUM the IIF:
=SUM(IIF(Fields!fund_no.Value = 1, Fields!last_wk_amt.Value, 0))
If your AMT field is not a decimal value, you'd need to convert the zero to a decimal to avoid an error about aggregating mixed data types:
=SUM(IIF(Fields!fund_no.Value = 1, Fields!last_wk_amt.Value, CDEC(0)))

Sum all fields from lookup SSRS [duplicate]

If i take a 4 day period it only shows capacity from the latest day, but I need to show the total capacity over 4 days. I try to sum the capacity wich is a lookup that looks like this:
=Lookup(Fields!ID.Value,Fields!Name.Value,Fields!capacity.Value, "table_1")
It does not work if I just add a Sum() in the beginning and I've tried to solve it with Code.Lookup_Sum but lookup_Sum gets red.
This is what I am trying to accomplish:
How can I do that?
Count Capacity in the QUERY as total Capacity

Single aggregate column / running value sum on chart

We're currently porting some excel reports to SSRS. One of those reports has a graph where the last column is the MTD (Month to date) average for both series (Availability and Availability Goal) just like the example below:
I did some research about RunningValue() but whenever I did it it would add a second bar to my graph (the running value would have the same group).
Is it possible to have only one aggregate column (just like the screenshot) ?
Thanks in advance,
One way would be to force the average through the SQL query. For example, if your resulting table shows days of the month, and the Availability value, you could UNION a "dummy" day (max days of the month + 1) with the averaged value. You can either add an addition column to your SQL for the label names, i.e. the "dummy" day would show "Average", or in SSRS you can change the Label expression to replace the last value with a text.

How do I compute an average of calculated averages in MS reportviewer/rdlc?

I've searched here and elsewhere on the web and have not found this exact problem/solution.
I'm building an rdlc report using the MS reportViewer - the report I'm creating is based on an existing spreadsheet where the average price across 6 months is calculated individually for each month, then the average of those prices is calculated as the 6 month period average price. Whether I agree with that methodology or if it's correct is irrelevant, I just need to know how to get an rdlc to do this.
For example:
Month Price1 Price2 Delta
May-12 $31.54 $30.03 $1.51
Jun-12 $36.27 $34.60 $1.67
Jul-12 $44.19 $42.00 $2.19
Aug-12 $38.96 $37.06 $1.90
Sep-12 $36.89 $35.08 $1.81
Oct-12 $35.57 $33.97 $1.60
Average $37.24 $35.46 $1.78
(sorry for the lack of a screen snip, I'm new and the system won't let me post an image...)
I've created a tablix that does the monthly averages computation - I use a group in the table to group the 6 months of data by month (and then hide the hourly price data so you only see the month total row) but I'm stuck on how to calculate the bottom row of the table which is the average of each column. (the average of the averages is not the same as the average of all 6 months of prices from the underlying data - that's what I've learned in this process... IOW, that was my first solution :-) )
What I tried to do to get the average of the averages was give the month total cell a name, MonthlyAvgPrice1, then in the bottom row, used this expression:
Avg(reportitems!MonthlyAvgPrice1.Value)
As I kind of expected, this didn't work, when I try to run the report, it gets a build error saying "The Value expression for the textrun 'Price1PeriodAvg.Paragraphs[0].TextRuns[0]' uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers."
Hopfully I've explained this well, does anyone know how to do this?
Thanks!
-JayG
Actually it is not clear from the question that how are you in particular binding the data to the report items, But from the given information what I understand is that you can
Try like this:
Right Click the tablix row and insert a row below
In the cell where you want to have this Average of Averages insert the following expression
=Sum(Fields!Price1.Value)/6
and similarly insert expression =Sum(Fields!Price2.Value)/6 and =Sum(Fields!Delta.Value)/6 in the other cells where you want to display the Averages
Of Course, you will change the Field names Price1,Price2 etc to the fields that you are getting the values from.
HTH

In Crystal Report print only first record in group and leave it summable

I have a table that lists every task an operator completed during a day. This is gathered by a Shop Floor Control program. There is also a column that has the total hours worked that day, this field comes from their time punches. The table looks something like this:
Operator 1 Bestupid 0.5 8 5/12/1986
Operator 1 BeProductive 0.1 8 5/12/1986
Operator 1 Bestupidagain 3.2 8 5/12/1986
Operator 1 Belazy 0.7 8 5/13/1986
Operator 2 BetheBest 1.7 9.25 5/12/1986
I am trying to get an efficiency out of this by summing the process hours and comparing it to the hours worked. The problem is that when I do any kind of summary on the hours worked column it sums EVERY DETAIL LINE.
I have tried:
If Previous (groupingfield) = (groupingfield) Then
HoursWorked = 0
Else
HoursWorked = HoursWorked
I have tried a global three formula trick, but neither of the above leave me with a summable field, I get "A summary has been specified on a non-recurring field"
I currently use a global variable, reset in the group header, but not WhilePrintinganything. However it is missing some records and upon occasion I will get two hoursworked > 0 in the same group :(
Any ideas?
I just want to clarify, I have three groups:
Groups: Work Center --> Operator --> Date
I can summarize the process hours across any group and that's fine. However, the hours worked prints on every detail line even though it really should only print once per Date. Therefore when I summarize the Hours Worked for an operator the total is WAY off because it is adding up 8hours for each entry instead of 8 hours for each day.
Try grouping by the operators. Then create a running total for the process hours that sum for each record and reset on change of group. In the group footer you can display the running total and any other stats for that operator you care to.
Try another running total for the daily hours but pick maximum as the type of summary. Since all the records for the day will have the same hours work the maximum will be correct. Reset with the change of the date group and you should be good to go.