Counting Rows From a Value in a SQL text box - please please can anyone help?
0
votes
0
answers
103
views
I just can't find an example of this anywhere and hoping someone can help.
I have a query which returns a list of care services and other fields based on the care service table values and calculated expressions. One of the calculated expressions for each row is as follows:
=iif(Fields!NoCareInspection.Value=0,1,0)+
iif(Fields!NoCareInspection.Value>2,1,0)+
iif((Fields!IncidentsPrevMth.Value-(Fields!NoofIncidentsLast12.Value/12)>0 AND
Fields!IncidentsPrev2ndMth.Value-(Fields!NoofIncidentsLast12.Value/12)>0),1,0)+
iif(Fields!ConcernsPer100Last12.Value-Avg(Fields!ConcernsPer100Last12.Value, "DataSet2")>0,1,0)+
iif(Fields!CurrManagerStatus.Value "Registered",1,0)+
iif((Fields!ManagerApplicationsLast24.Value+Fields!AbsencesLast24.Value)>2,1,0)+
iif((Fields!ENFMeetingsLast24.Value+Fields!FTCsLast24.Value+Fields!INsLast24.Value+Fields!NOPsLast24.Value+Fields!UPsLast24.Value)>0,1,0)+
iif(Fields!IncidentsPrev3Mths.Value =0,1,0)+
iif(Fields!NoofAFIsLast12.Value-Avg(Fields!NoofAFIsLast12.Value, "DataSet2")>0,1,0)+
iif(Fields!RPNotReg.Value >0,1,0)
This evaluates a number of field values from the care homes table and nicely calculates a risk score for each care home (row) -this works a charm.
Now what I need is a summary table to count how many rows had a total score of 0,1,2 and so forth. What I have tried is different permutations of this kind of statement:
=SUM(iif(iif(Fields!NoCareInspection.Value=0,1,0)+
iif(Fields!NoCareInspection.Value>2,1,0)+
iif((Fields!IncidentsPrevMth.Value-(Fields!NoofIncidentsLast12.Value/12)>0 AND
Fields!IncidentsPrev2ndMth.Value-(Fields!NoofIncidentsLast12.Value/12)>0),1,0)+
iif(Fields!ConcernsPer100Last12.Value-Avg(Fields!ConcernsPer100Last12.Value, "DataSet2")>0,1,0)+
iif(Fields!CurrManagerStatus.Value "Registered",1,0)+
iif((Fields!ManagerApplicationsLast24.Value+Fields!AbsencesLast24.Value)>2,1,0)+
iif((Fields!ENFMeetingsLast24.Value+Fields!FTCsLast24.Value+Fields!INsLast24.Value+Fields!NOPsLast24.Value+Fields!UPsLast24.Value)>0,1,0)+
iif(Fields!IncidentsPrev3Mths.Value =0,1,0)+
iif(Fields!NoofAFIsLast12.Value-Avg(Fields!NoofAFIsLast12.Value, "DataSet2")>0,1,0)+
iif(Fields!RPNotReg.Value >0,1,0)=1,1,0))
I thought it was going to run but got this message:
'Inner aggregates cannot specify a dataset scope'
I have spent a few days trying to untangle this - any help would be immensely appreciated.
Asked by Paula Morrison
(11 rep)
Jul 3, 2023, 10:58 AM
Last activity: Aug 8, 2023, 09:00 AM
Last activity: Aug 8, 2023, 09:00 AM