How to add total for calculated (using expression)column in SSRS - reporting-services

Column expression:
IIf(Left(Fields!EmployeeNo.Value,1)<>"2",Count(Fields!EmployeeNo.Value),"")
TOtal expression is:
Sum(IIf(Left(Fields!EmployeeNo.Value,1)<>"2",Count(Fields!EmployeeNo.Value),""))
if use this expression for total getting message as "#Error" in report preview.
Please tell me how to get this done.

Your column expression doesn't need a Count - that is for aggregation across multiple rows. Your total expression also can't have a Sum and a Count.
Try this for your column expression:
=IIF(Left(Fields!EmployeeNo.Value, 1) <> "2", 1 , 0)
and sum that for your total expression:
=Sum(IIF(Left(Fields!EmployeeNo.Value, 1) <> "2", 1 , 0))

Related

Calculate total sum for the grouping of child group using Aggregate sum or group by sum Expression

I am trying to calculate a sum based on Category of business
(Total sum of Type 1, Total sum of Type 2 and 3).
I created calculated fields for all 3 which is given below :
''=SUM(If(Fields!Category_of_business.Value="Type1",Fields!Selling.Value,0))''
For which I am getting an error that Aggregate functions are not allowed in calculated fields. Is there any workaround? Visual rep of SSRS table

sql count the date less than current date

I have a table where user input a target date, and then I want to output the count of names where their associated target date is greater than current date.
I tried but I'm getting the same results
below is the code
$select1_query = "
SELECT ACCOUNT_NAME
, COUNT(NCI_NUMBER)
, COUNT(CURDATE()>TARGET_DATE)
FROM sim_tracker
WHERE NCI_STATUS != 'Closed'
GROUP
BY ACCOUNT_NAME
";
Don't use count(). Use sum():
SELECT ACCOUNT_NAME,
COUNT(NCI_NUMBER),
SUM(CURDATE() > TARGET_DATE)
FROM sim_tracker
WHERE NCI_STATUS <> 'Closed'
GROUP BY ACCOUNT_NAME;
This works because MySQL treats booleans expressions as "1" for true and "0" for false in a numeric context. SUM() then counts the number of "true" values.
COUNT() does not work, because COUNT(<expression>) counts the number of non-NULL values. "true" and "false" are both non-NULL, so they both get counted.

How to use count number of rows which meet the condition in ssrs report?

In my report I want to count number of rows with condition. For example Count Mondays, count weekdays, count Saturdays, etc.
I try with this :
=countdistinct(iif(weekday(Fields!DATE_YYYYMMDD.Value,2)=1,Fields!N_ENTERED.Value,0))
but give me the result 18. I expected 1, because I have only 1 monday between 09.06.2019 and 16.06.2019
The entered value is entered calls from employees.
Your countdistinct is returning the number of unique values you have in your N_ENTERED field, not the number of Mondays.
To just count the number of Mondays, you need to reference the result of your iif instead:
=sum(iif(weekday(Fields!DATE_YYYYMMDD.Value,2)=1, 1, 0))

SSRS Position calculate Expression

I am trying to show the Postions of student on the basis of aggregate (aggregate )
The Aggregate expressions calculating on basis of (FINAL + MOCK + Asst)/3 which m doing on run time expression calculate...
Now i am unable to display the position positions Column highest the aggregate highest positions(1 OR 2 OR 3 ) positions
Is there any expression i can write to show positions column.
please help me m stuck
There's not a function that you can use - you'd just need to use some IIFs:
=IIF(FIELDS!Final.VALUE >= FIELDS!Mock.VALUE AND FIELDS!Final.VALUE >= FIELDS!Asst.VALUE, 1,
IIF(FIELDS!Mock.VALUE >= FIELDS!Final.VALUE AND FIELDS!Mock.VALUE >= FIELDS!Asst.VALUE, 2, 3))

SUM of a SUM in SSRS 2008

I've this report
Here I make the first sum because I've grouped values from each month (months are "Gennaio", "Febbraio", "Marzo" etc etc.). These values are hidden, but anyway I get the sum and I display the sum for each month.
Then I should make the second sum that use values for each month and display the total for each category. Categories are "TOTALE LAVORI RESTAURO", "TOTALE LAVORI EDILE" etc.)
This is the final sum, where I sum values from each category.
Everything is working well, but now I have to add a "month" parameter to the report that returns sums until a selected month. This parameter changes the sum 1 with this expression:
=Sum(IIf(Fields!mese.Value <= Parameters!mese.Value, Fields!costi.Value, 0))
Now, how should I change expression in SUM2 and SUM3 to work with this parameter?
If I copy that code, ther returns #Error and as far as I know I can't use ReportItems sum.
So any suggestion?
SUM #1 could remain Sum(Fields!costi.Value) because you need to display every months.
i.e.: display GIUGNO even if Parameters!mese.Value = 4 (APRILE).
So you have only to change SUM #2 and #3 because TOTALE LAVORI RESTAURO and TOTALI must show only costi from GENNAIO to Parameters!mese.Value; i.e. if Parameters!mese.Value = 4 display only GENNAIO-APRILE even if we have details about GIUGNO.
The expression gave error because you have NULL value in Fields!costi.Value or Fields!mese.Value: convert this value to zero in your DataSet and you won't have problems.