Click here to Skip to main content
15,741,407 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I have developed a report in what i want is to have a count of studentID for all male students(coded as 1) in grade 1.

here is what i have in rdlc

=iif(Fields!Sex.Value = 1 and Fields!grade.Value = 1,count(Fields!studentId.Value),0)

only the false part is being executed i dont know why. Would please assist me to establish where i might go wrong
CHill60 30-May-13 12:09pm    
Have you tried stepping through the code in debug mode and examining the contents of the fields. There is nothing wrong with the code you've posted so it has to be the data
mayeso 30-May-13 13:21pm    
but in the dataset/table these values(grade = 1 and sex =1) are there

.Value is Boolean then try
Fields!Sex.Value and Fields!grade.Value
if value is integer
maybe DBNull
test 1st for this
Share this answer
mayeso 31-May-13 13:27pm    
Thanks,i tried it, it didnt work, still executing the false part
put value <> 0 instead of =1
Boolean value = -1 in vb not 1
Share this answer
mayeso 31-May-13 14:27pm    
do you mean like this?
=iif((Fields!grade.Value <> 0 and Fields!Sex.value <> 0),count(Fields!studentId.Value),-1). This still returns the false part
mayeso 31-May-13 14:51pm    
The query i have that is used in the dataset is generating data like this;

Sex grade studentID
1 1 2009105012410059
1 1 2009105012410060
0 1 2009105012410063
0 1 2009105012410065

so in the rdlc i want to count all those with sex = 1 and are in grade 1 or vice versa, that is those with sex = 0 but are in grade 1. Like in the above sample i was supposed to get 2 for each sex
The following code is test and worked
Class TItem
    Public Property Sex As Integer
    Public Property Grade As Integer
    Public Property studentID As Long
End Class

Sub Main()

    Dim Items = { _
        New TItem With {.Sex = 1, .Grade = 1}, _
        New TItem With {.Sex = 1, .Grade = 1}, _
        New TItem With {.Sex = 0, .Grade = 1}, _
        New TItem With {.Sex = 0, .Grade = 1} _

    Dim ItemsList As New List(Of TItem)(Items)

    Dim n = Aggregate Item As TItem In ItemsList Where Item.Sex = 1 And Item.Grade = 1 Into Count()

End Sub
Share this answer
This sql return the result too

SELECT Sum(id) 
FROM Table
WHERE sex = 1 AND grade =1 ;
Share this answer
sum(iif(Fields!Sex.Value = 1 and Fields!grade.Value = 1, 1,0))
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900