Hi, very new to Access and am having trouble with custom XPercentile code (pulled from internet, credit Michel Walsh).
I'm using XPercentile successfully here:
Code:
=XPercentile("nmr","Control NMR",0.75)-XPercentile("nmr","Control NMR",0.25)
Control NMR query:
Code:
SELECT [NMR Distribution].Arm, [NMR Distribution].nmr, [NMR Distribution].Record_ID
FROM [NMR Distribution]
GROUP BY [NMR Distribution].Arm, [NMR Distribution].nmr, [NMR Distribution].Record_ID
HAVING ((([NMR Distribution].Arm)=0));
But the same is not working here:
Code:
=XPercentile("nmr","Control NMR No Outliers",0.75)-XPercentile("nmr","Control NMR No Outliers",0.25)
- not working
Control NMR No Outliers:
Code:
SELECT [NMR Distribution].Arm, [NMR Distribution].nmr, [NMR Distribution].Record_ID
FROM [NMR Distribution]
GROUP BY [NMR Distribution].Arm, [NMR Distribution].nmr, [NMR Distribution].Record_ID
HAVING ((([NMR Distribution].Arm)=0) AND (([NMR Distribution].nmr)<3));
For reference, this is the raw XPercentile code:
Code:
Public Function XPercentile(FName As String, _
TName As String, _
X As Double) _
As Double
' FName = Field name
' TName = Table name
' x = decimal percentile (0.68 for 68%)
' Return the minimum value for which x% of
' the values are lower or equal to it
XPercentile = DMin(FName, TName, _
"DCount(""*"", """ & TName & """, """ & FName & _
"<="" & [" & FName & " ]) >= " & _
X * DCount("*", TName))
End Function
The only difference in the queries is the restriction to values below 3, but this appears to cause a problem and I'm not sure why. Any help is appreciated, please let me know if more information is needed and I'll try my best!