SSRS adding a percentage column based on a specifc column category in a matrix/tablix - reporting-services

I have a matrix/tablix set up so there are 4 row groups going down the left-hand side and a column group called RegCompCategory:
When the report is run, the RegCompCategory column group produces 3 distinct columns based on the categories in the underlying data:
What I'd like to do is add another column before the RegCompCategory column group that will display a percentage of the "fully-marked" column against the "total" column:
I'm guessing I will need to write an expression for the fields highlighted above, but I'm not sure how to reference the RegCompCategory to identify specifically the "Fully-Marked" category of data.
Could someone give me a few pointers? Many thanks.

Try:
=Count(IIF(Fields!RegCompCategory.Value="Fully-Market",Fields!RegCompCategory.Value,Nothing))
/
Count(Fields!RegCompCategory.Value)
It will count the number of Fully-Market rows and divide by the total rows. I think that is what you are expecting.
Let me know if this helps you.

Related

Adding Totals for each column in table/Matrix with two row groups and a column group

I have a table/matrix with 3 groups, 1 column group and 2 rows groups.
I need to add a row at the bottom that will display totals on each column. I have tried working with the "right-click > Add Total" thingy but it only adds the static column "Total" but the grouped columns are blank; there's no expression.
How can I achieve this?
Your current design appears to have no numeric data to summarise, so when you add a total row, SSRS does not know what or how you want your aggregation to work.
You can manually add expressions to the textboxes total line, so if you wanted a count of results you could use something like.
=COUNT(Fields!AnswerText.Value)
If this does not help, explain what you want to see on your total row and how you would calculate it.

Query distinct row in Query Builder

I have a table like this:
I want to get distinct row from this. I use:
DB::table('dmspro_mys_campaign_product')->distinct()->get();
But it still give result with 3 rows. I expected 2 rows.
How I can fix this?
Simply pass the field name inside the distinct function. like this(in case if you want distinct based on 'compeign_code' column)
DB::table('dmspro_mys_campaign_product')->distinct('compeign_code')->get();
in case if you want to distinct the field based on more than one column value then you can use the select method.
In my opinion the answer is correct. District rows give you the results where every row is unique. Since there are slight variations between all three rows, you get all three because no row is exactly equal to another row.
I hope I could help,
Sebastian
You need a distinct value from dmspro_mys_campaign_product table so Database query needs pass column name.
DB::table('dmspro_mys_campaign_product')->distinct('product_id')->get();
You simply need to mention the column name in distinct('compeign_code').
DB::table('dmspro_mys_campaign_product')->distinct('compeign_code')->get();
Or you can try
DB::table('dmspro_mys_campaign_product')->groupby('product_id')->distinct()->get();
If you want to get only one column then you may use this.
DB::table('dmspro_mys_campaign_product')->distinct()->select('product_id');

SSRS Sum Amounts with different columns based on an expression

So i am trying to sum columns based on a condition from one group to another.
The first column is the expression that counts how many Meters are in that group by company.
in the photo it shows eight by that company that have a value of meter,
Then to the right is invoice amount
What i need to do is a conditional format for the expression that says if x company has 8 meters what is the total amount for all invoices that = meter.
I have tried a few ways but unable to get the count out of the expression under the column so i know it has something to do with my condition statement and not sure wher it is going wrong any help would be appreciated
=Sum(IIf(Fields!invoiceclass.Value = "METER" and Fields!companyname.Value, Fields!invoiceamount.Value , Nothing), "AR")
Try using:
=Sum(IIf(Fields!invoiceclass.Value = "METER", Fields!invoiceamount.Value,0))
I think you don't need to specify a scope since you want the sum be calculated per instance in the company group and you are using the expression in a cell inside the Company group scope.
Let me know if this helps.

SSRS sum values by different group and merge cells

I got a sum Table 1 from a dataset, grouped by a parent Group 1 and a child group 2.For C, it sums values for different Sites.
The table I really want is to merge the SumValue under one column and re-name the group, e.g., C1 & C2 instead of Site-C1 & Site-C2.
I have tried to rename the Group 2 from Site_C1 and Site_C2 to C1 and C2, but it still splits to different columns:
Thank you for your help in advance.
It is similar to a question you posted before. As I said in that moment you can use an expression to conditionally set the grouping settings in your matrix. Add a matrix and add the Group 1 to Column Groups
In the Group properties / Group on put this expression:
=IIF(
Fields!Group.Value="C",
RIGHT(Fields!Subgroup2.Value,2),
Fields!Group.Value
)
Note Subgroup2 is Group 2 in your case.
Put the same expression on the header (the selected cell in the screenshot). It will preview the following matrix:
Let me know if this helps.
I would add one ore more calculated field to the dataset. There you can add the values of the relevant columns like this:
=IIF(IsNothing(Fields!C10.Value), 0,Fields!C10.Value)
+ IIF(IsNothing(Fields!C11.Value), 0,Fields!C11.Value)
+ IIF(IsNothing(Fields!C11.Value), 0,Fields!C12.Value)
In your table, don't bind a column to C10, C11.. but bind it to the calculated field.

Error in finding sum of a group and Conditional Summing in SSRS Reports

I have an SSRS Report, in the database there is a column by name Total_running_hours.
There are more than one record for a single Cycle_number like more than 1 row with same Cycle_number but different Block_numbers and the value in Total_running_hours field will be same for all the rows with same Cycle_number. Eg. 1 Cycle number with 4 diff block_numbers contain same Total_running_hours for all 4 rows.
Now the problem is, in the group footer if I put this field then it will show the Total_running_hours value only once which is correct, but my final requirement is,
I need to get the sum of this field in the Report footer which need to display the sum group wise. No matter how many rows are there for a single Cycle_number it has to take only once and display the result.
I tried in different ways like
=sum(ReportItems!textbox204.Value) // name of text box in Group footer
Error: Report item expressions can only refer to other report items
within the same grouping scope or a containing grouping scope.
=sum(Fields!total_running_hours.Value,Group_name)
Error: The scope parameter must be set to a string constant that is
equal to either the name of a containing group, the name of a
containing data region, or the name of a data set.
Can any one please help me in getting the sum Group wise
Thank you in advance.
I found solution for this Problem.
We cannot simply sum the Total_Running_hours value as this would give us duplicates and the incorrect answer. We cannot sum the reporting services group as it goes out of scope
There is no SUM DISTINCT available in Reporting Services 2005 so we can't get the distinct value that way.
Since the query may not return a particular Cycle_Number Type we cannot use that as a filter.
The solution found was to add a column of the row number within a windowed set partitioned by the Cycle_Number like this
ROW_NUMBER() OVER (PARTITION BY Cycle_Number ORDER BY Cycle_Number ) AS 'RowNumber'
Then in the reports’ footer total column we put an expression that only takes the first row’s value to sum and converts all other rows to zero in that windowed set.
=SUM(IIF(Fields!RowNumber.Value=1,Fields!Total_Running_hours.Value,0))
After using this if u found any error in textbox like #Error
Then try this
=SUM(IIF(Fields!RowNumber.Value=1,CDbl(Fields!Total_Running_hours.Value),CDbl(0.0)))