SSRS: How can I get a dynamic list of values from a dataset column and a running count in ParentGroup footer - reporting-services

I have some data that has a result of a source or reason. They can be anthing in a long list of options, but I only want to count those that appear in the query results as a list with totals.
Example:
Property
Reason
PropA
Google
PropA
Referral
PropA
Billboard
PropA
Referral
PropA
NULL
In the Parent Row Group footer I would like to list each Reason that shows in the result set with a count, like a pivot table
Reason
Count
Google
1
Referral
2
BillBoard
1
...
I'm not really sure where to start. I could do it as a subreport, but if I can do it with only the one query I would prefer that. Thoughts? I thought of a LIST but not sure how to take the list and get a count. I'm kind of newish to SSRS, coming over from Crystal.
I've looked at a list but struggled with counts. Triend Column Group which gives an error on column span. Can do it in a subreport but prefer other methods if possible.

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.

How to get total from another tablix column? (SSRS)

Hello awesome people of stackoverflow!
I need help with a simple problem with my SSRS expression.
How could I do this in SSRS?
As you can on the 2nd table below in my excel screenshot.
for each row we divide -BC5...-BC10 to column/row BC4. To get the desired results for table 2 in excel column total 2018 into column/rows BC17 upto BC22.
I've tried referencing my textbox like this
ReportItems!TextBox1.Value / ReportItems!TextBox2.Value.
But got me the wrong values.
Can someone please help.
Thank you!
If those two tables are in the same table/tablix then it should work with the expression that you wrote (try to type it instead of copy paste sometimes that may work).
=(ReportItems!Textbox7.Value /ReportItems!Textbox1.Value) * 100
If they are not in the same Table/Tablix then you should write like the following:
=(Fields!ColumnName1.Value / Fields!ColumnName2.Value) * 100
Format your cells.
There is not enough info to give you an exact answer but you should be able to work it out.
The first thing you need to do is get the context of the aggregations you want to work with. So click on the cell containing the number you want to divide ([Sum(DiscountOERestated)] ). In the row and column groups panel near the bottom on the screen, look at the row group that is highlighted. For this example I'll assume the row group is called grpCategory.
Now we need to do the same for GrossCatalogRestated. However, GrossCatalogRestated in the top tablix does not appear to be an aggregate. I'll assume it should be the total GrossCatalogRestated for the dataset. For this exmaple, we'll say the dataset name is dsMyDataSet. If it's within a row group, just swap the dataset name out with the row group name that it sits in, just like we did for DiscountOERestated .
So you expression would look something like
=SUM(Fields!DiscountOERestated.Value, "grpCategory") / SUM(Fields!GrossCatalogRestated .Value, "myDataSetName")
This will give you a deicmal result, somehting like 0.025 . You then just need to set the format property to say, "p1", so it shows as 2.5%
If this does not work, edit your question to show the expressions in the cells you are working with along with the rowgroup and dataset names.

How to Sum the aggregates of a child group

This should be easy, but I am stuck.
I have a table listing some figures about Qualifications - to achieve which a dataset that is essentially a row per Student is being grouped on Qualification with a Parent Grouping on "Measure" (which is just a bucket of qualifications).
One of the columns is trying to work out the number of students (well, more properly the number of students with a value in a particular field, weighted by another field) in each Measure/Qualification. In the screenshot below, it's the "Pred. Avg" column on the right hand side.
So for the Qualification Row Grouping, that column is calculated by:
=CountDistinct(Iif(IsNothing(Fields!AVG_PTS.Value) = False, Fields!Learner_ID.Value, Nothing), "Qual") * Lookup(Fields!Qual_Code.Value, Fields!Qual_Code.Value, Fields!size.Value, "DS_KS5Nationals_LKP")
This works fine - the values of 35 and 11.5 in that rightmost column are correct for those rows. What the top row should be doing is simply adding up the values in the other rows to give me the number of students in this Measure, in this case to give 46.5. To do that the expression I am using is:
=Sum(CountDistinct(Iif(IsNothing(Fields!AVG_PTS.Value) = False, Fields!Learner_ID.Value, Nothing), "Qual") * Lookup(Fields!Qual_Code.Value, Fields!Qual_Code.Value, Fields!size.Value, "DS_KS5Nationals_LKP"), "Measure")
However as you can see in the screenshot, this returns 2917 instead.
So my question is; Why doesn't that work, and given that it doesn't work how can I, within a parent group, aggregate the results of aggregates inside a child group?
EDIT:
OK so, I have determined that the following works correctly:
=Sum(CountDistinct(Iif(IsNothing(Fields!AVG_PTS.Value) = False, Fields!Learner_ID.Value, Nothing), "Qual"), "Measure")
The problem there is that the Qual row that returns 11.5 is weighted to 0.5. I.E. it actually returns 23, and the Lookup(Fields!Qual_Code.Value, Fields!Qual_Code.Value, Fields!size.Value, "DS_KS5Nationals_LKP") is for that row returning 0.5 and altering it to 11.5...so the question becomes; "how do I force that ...*Lookup(Fields!Qual_Code.Value, Fields!Qual_Code.Value, Fields!size.Value, "DS_KS5Nationals_LKP") into the "Qual" scope, like the CountDistinct() is already in?
The issue here is that you're trying to aggregate values using that Lookup function which only returns one value. There are a couple ways you could go about doing this. One option would be to use the LookupSet function to get the applicable weightings. An even better option is to combine the data in your dataset so that the weighting is available without using a lookup. That way the function can recalculate an any grouping level without you having to force a scope on it. Also, CountDistinct ignores "Nothing" so you can do without the extra IIf statement. Hope that helps.

List box and Option group filtering 3 different rows in MAIN list box in MS Access 2013

I've been struggling with the following for a while and would be more than happy for some brainpower ;)
I have an Advanced filter form, which filters through orders via many different filters, currently the one that I can't make function is the following:
I have 4 controls on a form (all unbound):
ogProductType - option group that allows you to pick from 3 types of products
lbAllProducts - list box displaying all types of products. It has 2 rows, and gets filtered by tbSearchProducts which searches by the name of the product, but the lb is bound by the first row which is the product code. The filter is done by inserting criteria into the name row:
"Like "*" & [tbSearchProducts] & "*"".
tbSearchProducts - text box for searching the product by name. Has requery for lbAllProducts OnChange.
Main orders list box - lbOrders - which has many rows. The ones we care about in this case are ID; eProductCode; fProductCode; kProductCode. It is supposed to display all IDs of all orders where the filters are true (all orders where type 1 product is bought). In the query builder I have the following code as criteria for each them:
In lbOrders:
for eProductCode row
IIf([ogProductType]=1 And Len(Nz([lbAllProducts]))>0;[lbAllProducts];"")
for fProductCode row
IIf([ogProductType]=2 And Len(Nz([lbAllProducts]))>0;[lbAllProducts];"")
for kProductCode row
IIf([ogProductType]=3 And Len(Nz([lbAllProducts]))>0;[lbAllProducts];"")
I want the Main list box to be filtered depending on what type of product was chosen (eProductCode is chosen with the option group set on First option = 1; fProductCode = 2; kProductCode=3), but ignore the other 2 rows totally. Sadly, with that false statement saying the criteria for the field is "", in case it was not chosen via the option group, it doesn't work.
How can I stack 3 criteria, all taking values from the same list box, but only if option group is the right on, without them interfering with each other?
I tried with "*" in false and it doesn't work...
Any ideas?
I've solved it :)
You simply never use the criteria to filter the 3 rows... You just use the field itself to load the proper row that you need and put in criteria...
Here is the code for the field:
Expr1: IIf([obProducts]=1 And Len(Nz([lbSearchProduct]))>0;[tblOrders]![еProductCode];IIf([obProducts]=2 And Len(Nz([lbSearchProduct]))>0;[tblOrders]![fProductCode];IIf([obProducts]=3 And Len(Nz([lbSearchProduct]))>0;[tblOrders]![kProductCode])))
And in criteria for that row I set the list box that has the bound column for product code lbAllProducts