how to get sum(group) value in rdlc - reporting-services

I am developing report in RDLC (VS 2012)
below is my report
In this report i have two group total value matrix table.
I want to minus Sum(income) and sum(expenses).
Total should be show as 2121.00
how its possible ?

Try using:
=SUM(IIF(Fields!VoucherType.Value = "Income",Fields!Amount.Value,0))-
SUM(IIF(Fields!VoucherType.Value = "Expenses",Fields!Amount.Value,0))
Update
Textbox outside of the tablix.
If you want to show the total outside of the tablix you need to set the scope of the expression, in this case the dataset:
=SUM(IIF(Fields!VoucherType.Value = "Income",Fields!Amount.Value,0),"DataSetName")-
SUM(IIF(Fields!VoucherType.Value = "Expenses",Fields!Amount.Value,0),"DataSetName")
Replace DataSetName by the actual name of your dataset.

=SUM(IIF(Fields!TransactionType.Value = 1), Fields!Amount.Value, 0) -
SUM(IIF(Fields!TransactionType.Value = 2), Fields!Amount.Value, 0)

Related

How to not COUNT a value in SSRS matrix when value is NULL

I cannot make the my expression NOT count a NULL value in my SSRS matrix.
In my SSRS matrix, I have 2 columns one for AppraisalCompany and a count under the SubmittedDate column. In my report this what is happening:
Per Derrick's suggestion here is the change I made in the ColumnGroup properties for the SubmittedDate:
Here is my expression change in the ColumnGroup properties:
Unfortunately I got this error:
I'm suspicious of your Dataset, I'm not entirely sure how you're getting a null value to return 1 in the COUNT. I have been unable to reproduce your results.
Dataset Query
SELECT 'Drive In' AS AppraisalCompany, NULL AS SubmittedDate
UNION
SELECT 'Photo App - English', 'Dec-18'
Next I created a Row Group on AppraisalCompany and a Column Group on SubmittedDate.
I filtered the column group to remove the null grouping, using the expression =IsNothing(Fields!SubmittedDate.Value), operator <>, and Value true.
In the textbox in the matrix I used [Count(SubmittedDate)].
OUTUT
Appraisal Company | Dec-18
-------------------------------
Drive In | 0
Photo App - English | 1
By a Decimal (Number) datatype Nothing and 0 are the same. You can test this.
Put a tablix into your report with year from 2017 to 2019. Then put the year in a column of the tablix as a number format, then write the following expression in the detail textbox:
=CDec(IIF(CDec(Fields!Year.Value) = 2017, 0, Nothing))
After executing your report you will notice that every value in the year column is 0.
The same goes for the check. Both of these expressions will always return Yes. I basically check for 0 and the second one for for Nothing:
=IIF(CDec(IIF(CDec(Fields!Jahr.Value) = 2017, 0, Nothing)) = 0, "Yes", "No")
=IIF(CDec(IIF(CDec(Fields!Jahr.Value) = 2017, 0, Nothing)) = Nothing, "Yes", "No")
But remember your textbox/column has the be a number format.
So if you want to return Nothing and you display it in a number format textbox, it will show you a 0.
With this in mind it will make sense that a Count() returns the value 1 for 0 AND Nothing. So basically this will do the trick:
'Cont
=Sum(IIF(Fields!YourValue.Value = Nothing, 0, 1))

SSRS: How to add an condition in the expression while counting rows?

I need help with writing a conditional expression for counting specific rows of the dataset using which I determine to make a textbox visbile
DataSet_Example
Name value Level
ABC 12345 PG1
DEF 45677 PG2
FEG 98098 PG1
I want to count the rows based on the level. Something Like the one below
iff(CountRows("DataSet_Example").Level == PG1 < 1)
How do I do it in SSRS expressions?
You need insert a row group for "Level" and then set your visibility expression for each row to the following:
=IIF(CountRows("Level") > 1 , condition if true, condition if false )

SSRS Grouping Data Together

I have a report that lists securities that are held and there security types. I want to some business logic that says security types 1, 2 and 3 are Equities, while security types 4, 5 and 6 are Bonds and then I want to group the report by these. Any idea how to do that? Right now the report lists each individual security type.
amend your dataset: within your select sql statement , lastly add the following:
CASE WHEN [security types] IN ('1', '2', '3') THEN 'Equities'
WHEN [security types] IN ('4', '5', '6') THEN 'Bonds'
ELSE 'others'
END AS securitiestype
Then with in your SSRS report you can now use securitiestype as a group filter.
A good way to do this is to add a calculated field to your dataset that evaluates this logic. Then you can group on this new column in the report.
Go to your dataset properties
Add a calculated field
Name it and enter the expression for it. It could be something like this:
=Switch(Fields!SecurityType.Value = 1 OR Fields!SecurityType.Value = 2 OR Fields!SecurityType.Value = 3, 'Equity'
,Fields!SecurityType.Value = 4 OR Fields!SecurityType.Value = 5 OR Fields!SecurityType.Value = 6, 'Bond', true, 'Other')
Add a grouping to your table/matrix using this new column

SSRS Multiple Field Values Not Passing As Parameters To Drilldown Report

I have not found a suitable answer to my following problem after much searching.
I have a summary report which shows the total number of appointments by month grouped by specialty name and diagnosis.
Specialty_Name Diagnosis Code Feb Mar Apr
Neurology G35X 0 3 4
G379 8 5 7
Total For Spec 8 8 11
Rheumatology H051 4 9 2
M059 6 10 3
Total For Spec 10 19 5
When I click on the field (ie 11 for Neurology Total For Spec, Apr), which is =COUNT((Fields!Appointment_ID.Value), I want to pass each of the Appointment_IDs to a sub query as the parameter to display the associated client details. However, when I prepare the sub query and drill down report in a manner that I have used before I am only getting the result of the first Appointment_ID; not each one.
The sub query report is set up with the parameter #Appointment_ID VARCHAR(MAX) and a WHERE clause:
CAST(App.App_ID AS VARCHAR(MAX)) in (
SELECT * FROM Serve1.dbo.CreateParameterTable(#Appointment_ID,',')
)
The CreateParameterTable is a function on our server which should handle the string from the summary report and does so on other reports.
(
#StringInput NVARCHAR(MAX)
, #SplitBy NCHAR(1)
)
RETURNS #OutputTable TABLE ( [String] NVARCHAR(36) )
AS
BEGIN
DECLARE #String NVARCHAR(36)
WHILE LEN(#StringInput) > 0
BEGIN
SET #String = LEFT(#StringInput,
ISNULL(NULLIF(CHARINDEX(#SplitBy, #StringInput) - 1,
-1), LEN(#StringInput)))
SET #StringInput = SUBSTRING(#StringInput,
ISNULL(NULLIF(CHARINDEX(#SplitBy, #StringInput),
0), LEN(#StringInput))
+ 1, LEN(#StringInput))
INSERT INTO #OutputTable ( [String] )
VALUES ( #String )
END
If I manually type in multiple Appointment_IDs to my drill down report I get the expected result. Therefore it appears that either my Summary Report is not passing out a string or it is not being handled correctly by the function or the sub report does not like the output of the function Which as I have said works on other reports we have written. I'm stumped.
How to begin troubleshooting your specific problem
Because you've said you can get the subreport working by supplying a string of values as desired, then it appears the problem is with the report providing the delimited string. Before you can fix the issue, you need to see the delimited string being passed to the subreport - so add it to the tablix. Use the same function you're using to reference the value in the "Go to Report" action and add it as a tooltip to each count. That way you can see the string being prepared and tweak your logic until it comes out correctly.
How I would solve your problem
What you're trying to accomplish as a multi-valued parameter is, as I see it, unnecessarily complicated.
In your tablix, you have a set way of organizing the results. You have specialty name, diagnosis, and month (presumably of the diagnosis or date served).
That's three parameters you can pass through to a sub-report. Using similar sql logic as exists in your main report, you can isolate those 11 simply by knowing the values of those three fields plus the year. Obviously, you will need to do some work to find diagnosis/service dates that fall into a given month, but that's not too hard:
Where Month(Date_of_Service) = #Month
and Year(Date_of_Service) = #Year
and Specialty_Name = #Specialty
and Diagnosis_Code = #Diagnosis

SSRS: Add multiple if statements

I am using SSRS to add certain values in a column together. If the Service ID is 13,15,18,or 19 I want it too add these values together. Right now I have:
=IIf(Fields!ServiceID.Value = 13,Fields!TermPrimary.Value, Nothing) + IIf(Fields!ServiceID.Value = 15,Fields!TermPrimary.Value, Nothing) + IIf(Fields!ServiceID.Value = 18,Fields!TermPrimary.Value, Nothing) + IIf(Fields!ServiceID.Value = 19,Fields!TermPrimary.Value, Nothing)
I thought This would allow me to add these values together, instead it only shows me the exact same values as the table below it showing serviceID 13. How do I add these figures together?
Your Service ID field will always be a single number and never equal to 13 AND 15 on the same line.
I think you want to Group your column by some other field and SUM the TermPrimary for that group IIF the ServiceID is one of your given values.
=SUM(IIf(Fields!ServiceID.Value = 13 OR Fields!ServiceID.Value = 15 OR Fields!ServiceID.Value = 18 OR Fields!ServiceID.Value = 19, Fields!TermPrimary.Value, 0)