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

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.

Related

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.

SSRS report pass multiple VALUES to drill through report parameter

I created a report with 5 fields in a hierarchical order:
Order Date
Time of Day (AM/PM)
Parent Name (aka customer)
Product Line
BIC Part Number (aka Item)
Each field expands down to the next level, so order date expands to time of day, etc.
I want to create a drill through report so that the user can click on each level of the hierarchy and see the detail.
This works fine at the lowest level - Item - because only 1 values from each field has to be passed to the drill through report parameter. However, when I try, for example, to drill through based on Product Line, there will usually be 3 or 4 Items within this product line. In the Go To action, I have the drill through parameter "bic_part" set to the main report FIELD value "BIC Part Number".
I have the tablix on the drill through report set where "BIC Part Number" IN [#bic_part].
I just want to be clear, I am passing a set of report field values to the drill through report parameter, not parameter to parameter.
I have tried using expressions with =Split(Join(field value),","),",") and all variations on that. I can't seem to get the child report filters to accept multiple values from the BIC Part Number field from the parent report.
I also tried omitting the BIC Part Number value in the go to report section, but it would not let me.
All of the parameters in the child report are set to accept multiple values. My data source for both reports is the same stored proc, so I can add a query filter. I would appreciate any help.
I think each sub report link needs to be slightly different.
In the subreport, each parameter needs to accept null and your query needs to look for
(FieldName = #FieldNameParameter or #FieldNameParameter is null)
This will allow you to pass the lowest possible solid value, then null for all child values.
If we're looking at the Parent_Number level, on that subreport link you would pass Fields!Parent_Number.Value and then Nothing for each of the lower parameters (Product_Line, BIC_Part_Number).
This will allow you to filter on the lower common denominator in your sub report - Part_Number for this link, Product_Line for the next one down, etc.
I've used this logic in reports before, so it does work. Let me know if my explanation needs clarification - it's Friday afternoon..

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

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:

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.

SSRS: Get values from a particular row of DataSet?

My dataset currently has 12 rows of data. Each representing data for a month. I would like to have variance of a column between to rows, the rows being last & last but one i.e., latest month and previous month's data.
It could have been simple if I were to work on tablix but thats not the case. I want those values for a textbox.
Any ideas on it anyone?
I hope you are using SSRS 2008R2:
R2 introduced the Lookup function that is perfect for this scenario.
=Lookup( Fields!ProductUID.Value ,Fields!ProductID.Value,Fields!Price.Value,"PriceDataSet")
The Lookup function above will evaluate the first parameter ("Fields!ProductUID.Value") in the current dataset, then look for a matching value in the field specified in the second parameter ("Fields!ProductID.Value") in the dataset specified in the fourth parameter. The value of the third parameter is then evaluated in that row of the dataset and returned.
A little convoluted, but very helpful.
In your case, you can use this in a textbox with a calculated a static number:
=Lookup(
Month(DateAdd(DateInterval.Month, -1, GetDate())),
Fields!MonthID.Value,
Fields!Name.Value,
"DataSet1")
This should calculate a number for last month, then look for a match in DataSet1.
In this example I have a tablix with Statecode and name as below
enter image description here
Suppose you want to display the name of state of CA, write an expression as -
=Lookup(
"CA" ,
Fields!StateCode.Value,
Fields!StateName.Value,
"ReportData"
)
This will return 'California' in the text box
I ran across this post while trying to solve a similar problem but with columns of double data type. Not sure why but SSRS did not want to return my first row using LOOKUP in combination with ROW_NUMBER in SQL(If someone can solve that all the better). I ended up using a SUM(IIF) instead. Hopefully, this is useful for someone else.
=Sum(IIF(Fields!RowNum.Value=1,CDBL(Fields!MyNumericColumn.Value),CDBL(0)))
Note: If SSRS complains about data types, just cast both parts of the IIF to the desired data type.