SSRS how to get a running total of inventory amounts IN and OUT from START DATE to END DATE? - reporting-services

i have a stored proc returning inventory amounts between a start and end date.
the QTY field shows on-hand inventory adjustments by date, either IN or OUT.
i have a "run balance" field that needs to show the total QTY each day. if the InOut field is 0, it's QTY in. if it's a 1, its QTY out. the values reflected in In and Out are coded that way.
EXAMPLE. if i start on 4/1/14 with 5216. then 1061 of product is made on 4/1/14 i need the run balance to take 5216 and add 1061 on the next line. the next line should read 6277 instead of 1061. then if some is shipped, take 6277 and subtract, and so on.
i tried the running value on QTY, but it just repeats the QTY. doesn't calculate anything.
=RunningValue(Fields!QTY.Value,Sum,"Details")
i tried to post an image of my report preview, but i don't have the reputation ;-)
any help would be MUCH appreciated.
EDIT: OK, i tried this code block:
= Switch(RunningValue(Iif(Fields!InOut.Value = 0, Fields!QTY.Value,0),Sum,"Details"),
RunningValue(Iif(Fields!InOut.Value = "1", Fields!RunBalance.Value - Fields!QTY.Value,0),Sum,"Details"))
and i am getting a 0 on the sum fields, and #Error on the subtraction fields. but, i think this is more the direction i need to go (i hope)....but i am still not getting it.

There are a couple of things to look at here.
First, you specify the Scope of "Details" in your RunningValue expression... By default this group will have no grouping value, i.e. each row in the dataset will be in its own group. Which means the RunningValue will only ever be applied to one row only. Change the Scope to "MyDataset" or Nothing, whatever is appropriate.
Secondly, you need to consider how the InOut field affects the RunningValue.
I have created a simple Dataset:
And a simple table:
The Balance expression is:
=RunningValue(IIf(Fields!InOut.Value = 0, Fields!QTY.Value, Fields!QTY.Value * -1)
, Sum
, Nothing)
You can see this changes the Scope from your original statement, and also applies a multiplier to QTY based on InOut.
Works OK for my sample data:

Related

How to get a value of cell based on condition from 2nd group in same tablix in RDLC report

I am working with RDLC report, where I have a very specific customer requirement to print a summary at the end of Report.
Please refer to image below for clear understanding:
Report summary is generated based on two Groups: Resource (No), and Task Wage Type.
1st tablix group = No.
2nd tablix group = Task Wage Type.
I need to generate an average per resource where:
Average = Total Cost / Quantity (where Task Wage Type = Hourly Task Wage)
So, I am working on extracting the value for Quantity where Task Wage Type = Hourly Task Wage and show it in Total Column for each group.
How can I achieve this?
Currently I have written this expression to achieve results, but its throwing an error as shown in picture above
=Sum(CDec(Fields!Total_Cost.Value), "Resource_No1")/Sum(IIF(UCase(Fields!WT_TaskWageType.Value)="HOURLY TASK WAGE", CDec(Fields!Quantity.Value), 1), "Resource_No1")
Finally my RDLC tablix image is shown below where I have two groups
How to resolve this error?
I can't see too much wrong with your expression so I would try to simplify things and build each part of the expression up until you get an error.
Two points though...
You should not need to specify the scope "Resource_No1" as it appears that the textbox is already within the correct scope (it's in he Resource_No1 group's rows).
Also, you appear to be adding 1 into your sum amount when the task wage type does not match your criteria. You should use 0 or nothing there instead I guess.
You could just try this to start with and then if that does not work, build up each part of the expression slowly.
=Sum(Fields!Total_Cost.Value)
/
Sum(IIF(UCase(Fields!WT_TaskWageType.Value)="HOURLY TASK WAGE",
Fields!Quantity.Value,
Nothing)
)
If you still get errors, try returning just the second part of the expression and see what you get.
I just tried this on a similar setup and it worked as expected.

Trouble creating nested SUM IIF expression in SSRS

I am new to SSRS and have a SUM(IIF question.
My data set contains four columns: Date, GroupID, PlanPaid, and NetworkIndicator.
Here is an example of the data set:
I am trying to SUM the [PlanPaid] amount when [NetworkIndicator] = "In Network".
However, I need this amount broken up by the [Date]. I tried accomplishing this by creating the expression:
=Sum(IIf(Fields!NetworkIndicator.Value = "In Network"
, Fields!PlanPaid.Value
, Nothing)
, "Claims_Rolling12")
But this expression returns the same amount (total) across all [Dates]. How do I break it up so that it is grouped by the correct [Date]?
Here is a photo of my Tablix and my current Groups: [Tablix and Groups]
And here is a photo of the output: [Output]
You haven't said where you want this sum to appear, so the answer here might not work. If it doesn't then edit your question to show what you expect the output to look like based on your sample data.
I'm assuming here that you want to add a new column to the report that shows "In Network total" by date.
The easiest way to do this is to add a row group that groups by date, then within this group you can use a simple expression, like the one you tried, but without specifying the scope.
=SUM(IIF(Fields!NetworkIndicator.Value = "In Network", Fields!PaidPlan.Value, Nothing))
This expression will only sum rows that are within the current scope, in this case the scope will be the row group you created to group by dates.
As IO said, if this is not helpful, edit your question and show what you expect your end result to look like, based on the sample data you supplied and then I can look at it again.

SQL/mysql - how to display two columns with different value from 1 table

I am trying to make a query for approval of documents, where the result display the name and signature with date. How can I get the date for two people approving the document?
Select Uname
case when stepcode=1 then 'approver1' end as 'name of person'
case when stepcode=1 then 'approver1' end as ' date of signed noted'
case when stepcode=2 then 'approver2' end as 'date of signed approved'
from table
I tried this, but only one result showed up. Only the name, signature and date of the first approval displayed.
We can only answer this by making some assumptions:
the field stepcode denotes what stage of the sign off process the record is at
value of 1 means noted and value 2 means approved. A value of 0 means nothing has happened yet
approver1 and approver 2 are NULL if the action has not yet taken place
If all of the above is true, then there should be no requirement to have a CASE statement for the fields... just including the fields within the SELECT statement will bring the values through if they have been completed.
Some validation of data might be required here though if you are not getting the results you are expecting. Running some rough counts for each of the steps and for where they have values in the approver fields would help to make sure your code is working. The following should give you something to work with:
SELECT
stepcode
COUNT(TableID) AS NumberAtStep
FROM table
GROUP BY stepcode
Using these counts, you can then run your statement without the CASE statements and run a manual count to ensure you are seeing the right number of records with the relevant populated columns for each step.
Further information will be required to delve into your problem further however

Calculated field in SSRS

I have tried to create a calculated field that will show the number of customer transactions processed within 15 minutes.
I have added the expression:
=count(fields!wait.Value<15)
However, when I run the query I'm getting the error message : 'expression used for the calculated field includes an aggregate RowNumber...'
Can you advise please on how to create a calculated field so I can capture the value I want?
I have tried = SUM(IIF(Fields!wait.Value < 15 , 1, 0)) to no avail.
With many thanks.
Calculated fields added to datasets can't have aggregate functions. The calculated field is essentially adding an extra column to your dataset. It sounds like you may want a variable? Used elsewhere in the report, your second expression would work, or the similar
=Count(IIf(Fields!wait.Value<15, 1, Nothing))
would work too.

Running Value Chart in SSRS - How to get each series to start at 0?

I have a table in SSRS, with income from two campaigns.
My columns are:
serialnumber
DateOfPayment
PaymentAmount
DaysSinceCampaign
Campaign
I want my chart to plot a running total of paymentamount by DaysSinceCampaign for each campaign (bs13 and bs12). I'm pretty close, as shown above - but for some reason, the BS13 campaign starts at 20,000, appearing to be adding on to BS12 - when it is supposed to start at 0.
In the Values section for Chart Data, I have used this formula:
=RunningValue(Fields!PAYMENTAMOUNT.Value,SUM,nothing)
I have tried changing 'nothing' to "campaign", and have tried defining 'Campaign' as a row group and a column group - but it keeps returning the same error: that the scope parameter must be set to a string constant equal to a containing group.
The scope here needs to be the name of the Series Group you set up in the chart, not the Column Group of the Tablix that is set up below, something like:
I created a simple test based on:
With the Chart data expression set to:
=RunningValue(Fields!PaymentAmount.Value, Sum, Nothing)
I got the following:
Which is incorrect, but similar to what you're seeing.
If I change the expression to:
=RunningValue(Fields!PaymentAmount.Value, Sum, "Chart1_SeriesGroup1")
I get the following:
Which is correct, so it seems like you're just going to have to set the Scope to the correct Series Group name.