Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

NthLargest

Posted on 2009-04-10
12
Medium Priority
?
422 Views
Last Modified: 2012-05-06
I have a report set with a parameter - Select # of WOs to display - 1, 2, 3, etc through 10.
 Issue  when you select 5  and there are only 4 WOs  no records return?
Thank you.

if shared stringvar rowsuppress_sv = '1'
  then {WORKORDER.REPORTDATE} <= nthlargest(1,{WORKORDER.REPORTDATE})
  else if shared stringvar rowsuppress_sv = '2'
         then {WORKORDER.REPORTDATE} <= nthlargest(2,{WORKORDER.REPORTDATE})
         else if shared stringvar rowsuppress_sv = '3'
                then {WORKORDER.REPORTDATE} <= nthlargest(3,{WORKORDER.REPORTDATE})

Open in new window

0
Comment
Question by:washvt
  • 6
  • 6
12 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 24119796
Try this

if shared stringvar rowsuppress_sv = '1'then
    {WORKORDER.REPORTDATE} <= nthlargest(1,{WORKORDER.REPORTDATE})
else if shared stringvar rowsuppress_sv = '2' then
(    
     if (Count(,{WORKORDER.REPORTDATE}) >= 2 then
         {WORKORDER.REPORTDATE} <= nthlargest(2,{WORKORDER.REPORTDATE})
     else
         {WORKORDER.REPORTDATE} <= nthlargest(Count(,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE})
)
else if shared stringvar rowsuppress_sv = '3'    then
(    
     if (Count(,{WORKORDER.REPORTDATE}) >= 3 then
         {WORKORDER.REPORTDATE} <= nthlargest(3,{WORKORDER.REPORTDATE})
     else
         {WORKORDER.REPORTDATE} <= nthlargest(Count(,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE})
)

Similarly for each N

mlmcc
0
 

Author Comment

by:washvt
ID: 24163015
Tried this but no success - please take a look at my formula - Thank you.
Questions
For this line do I put in the number 2, 3 etc?  -     (Count(2,{WORKORDER.REPORTDATE}),    
{WORKORDER.REPORTDATE} <= nthlargest(Count(,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE})

When I check validation of the report I get-  ) is missing -  after >= 2 then - then is hightlighted
)

if shared stringvar rowsuppress_sv = '1'then
   {WORKORDER.REPORTDATE} <= nthlargest(1,{WORKORDER.REPORTDATE})
    else if shared stringvar rowsuppress_sv = '2'then
    (if (Count(2,{WORKORDER.REPORTDATE}) >= 2 then
    {WORKORDER.REPORTDATE} <= nthlargest(2,{WORKORDER.REPORTDATE})
    else {WORKORDER.REPORTDATE} <= nthlargest(Count(2,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
        else if shared stringvar rowsuppress_sv = '3' then
        (if (Count(,{WORKORDER.REPORTDATE}) >= 3 then
        {WORKORDER.REPORTDATE} <= nthlargest(3,{WORKORDER.REPORTDATE})
        else {WORKORDER.REPORTDATE} <= nthlargest(Count(3,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
            else if shared stringvar rowsuppress_sv = '4' then  
            (if (Count(4,{WORKORDER.REPORTDATE}) >= 4 then
            {WORKORDER.REPORTDATE} <= nthlargest(4,{WORKORDER.REPORTDATE})
            else {WORKORDER.REPORTDATE} <= nthlargest(Count(4,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
                else if shared stringvar rowsuppress_sv = '5' then  
               (if (Count(5,{WORKORDER.REPORTDATE}) >= 5 then
                {WORKORDER.REPORTDATE} <= nthlargest(5,{WORKORDER.REPORTDATE})
                else {WORKORDER.REPORTDATE} <= nthlargest(Count(5,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
                    else 1=0
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 24174060
Since you have a ( after IF you need one before THEN

if shared stringvar rowsuppress_sv = '1'then
   {WORKORDER.REPORTDATE} <= nthlargest(1,{WORKORDER.REPORTDATE})
    else if shared stringvar rowsuppress_sv = '2'then
    (if (Count(2,{WORKORDER.REPORTDATE}) >= 2) then
    {WORKORDER.REPORTDATE} <= nthlargest(2,{WORKORDER.REPORTDATE})
    else {WORKORDER.REPORTDATE} <= nthlargest(Count(2,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
        else if shared stringvar rowsuppress_sv = '3' then
        (if (Count(,{WORKORDER.REPORTDATE}) >= 3) then
        {WORKORDER.REPORTDATE} <= nthlargest(3,{WORKORDER.REPORTDATE})
        else {WORKORDER.REPORTDATE} <= nthlargest(Count(3,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
            else if shared stringvar rowsuppress_sv = '4' then  
            (if (Count(4,{WORKORDER.REPORTDATE}) >= 4) then
            {WORKORDER.REPORTDATE} <= nthlargest(4,{WORKORDER.REPORTDATE})
            else {WORKORDER.REPORTDATE} <= nthlargest(Count(4,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
                else if shared stringvar rowsuppress_sv = '5' then  
               (if (Count(5,{WORKORDER.REPORTDATE}) >= 5) then
                {WORKORDER.REPORTDATE} <= nthlargest(5,{WORKORDER.REPORTDATE})
                else {WORKORDER.REPORTDATE} <= nthlargest(Count(5,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
                    else 1=0

mlmcc
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:washvt
ID: 24188343
Made change - now getting error message - A Field is required here - hightlighting the 2 - in (Count(2,{

 (if (Count(2,{WORKORDER.REPORTDATE}) >= 2) then

Thank you.

if shared stringvar rowsuppress_sv = '1'then
   {WORKORDER.REPORTDATE} <= nthlargest(1,{WORKORDER.REPORTDATE})
    else if shared stringvar rowsuppress_sv = '2'then
    (if (Count(2,{WORKORDER.REPORTDATE}) >= 2) then
    {WORKORDER.REPORTDATE} <= nthlargest(2,{WORKORDER.REPORTDATE})
    else {WORKORDER.REPORTDATE} <= nthlargest(Count(2,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
        else if shared stringvar rowsuppress_sv = '3'then
        (if (Count(3,{WORKORDER.REPORTDATE}) >= 3) then
        {WORKORDER.REPORTDATE} <= nthlargest(3,{WORKORDER.REPORTDATE})
        else {WORKORDER.REPORTDATE} <= nthlargest(Count(3,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
            else if shared stringvar rowsuppress_sv = '4' then  
            (if (Count(4,{WORKORDER.REPORTDATE}) >= 4) then
            {WORKORDER.REPORTDATE} <= nthlargest(4,{WORKORDER.REPORTDATE})
            else {WORKORDER.REPORTDATE} <= nthlargest(Count(4,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
                else if shared stringvar rowsuppress_sv = '5' then  
               (if (Count(5,{WORKORDER.REPORTDATE}) >= 5) then
                {WORKORDER.REPORTDATE} <= nthlargest(5,{WORKORDER.REPORTDATE})
                else {WORKORDER.REPORTDATE} <= nthlargest(Count(5,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
                    else 1=0
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 24200626
COunt requires the field.  Delete the 2, and 3, etc

if shared stringvar rowsuppress_sv = '1'then
   {WORKORDER.REPORTDATE} <= nthlargest(1,{WORKORDER.REPORTDATE})
    else if shared stringvar rowsuppress_sv = '2'then
    (if (Count({WORKORDER.REPORTDATE}) >= 2) then
    {WORKORDER.REPORTDATE} <= nthlargest(2,{WORKORDER.REPORTDATE})
    else {WORKORDER.REPORTDATE} <= nthlargest(Count(2,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
        else if shared stringvar rowsuppress_sv = '3'then
        (if (Count({WORKORDER.REPORTDATE}) >= 3) then
        {WORKORDER.REPORTDATE} <= nthlargest(3,{WORKORDER.REPORTDATE})
        else {WORKORDER.REPORTDATE} <= nthlargest(Count(3,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
            else if shared stringvar rowsuppress_sv = '4' then  
            (if (Count({WORKORDER.REPORTDATE}) >= 4) then
            {WORKORDER.REPORTDATE} <= nthlargest(4,{WORKORDER.REPORTDATE})
            else {WORKORDER.REPORTDATE} <= nthlargest(Count(4,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
                else if shared stringvar rowsuppress_sv = '5' then  
               (if (Count({WORKORDER.REPORTDATE}) >= 5) then
                {WORKORDER.REPORTDATE} <= nthlargest(5,{WORKORDER.REPORTDATE})
                else {WORKORDER.REPORTDATE} <= nthlargest(Count(5,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
                    else 1=0

mlmcc
0
 

Author Comment

by:washvt
ID: 24206257
Thanks for your assistance.  

Now getting error message - A Field is required here - hightlighting the 2 - in (Count(2,{
At the <= nthlargest (Count(2,{WORKORDER.REPORTDATE})

if shared stringvar rowsuppress_sv = '1'then
   {WORKORDER.REPORTDATE} <= nthlargest(1,{WORKORDER.REPORTDATE})
    else if shared stringvar rowsuppress_sv = '2'then
    (if (Count({WORKORDER.REPORTDATE}) >= 2) then
    {WORKORDER.REPORTDATE} <= nthlargest(2,{WORKORDER.REPORTDATE})
    else {WORKORDER.REPORTDATE} <= nthlargest(Count(2,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
        else if shared stringvar rowsuppress_sv = '3'then
        (if (Count({WORKORDER.REPORTDATE}) >= 3) then
        {WORKORDER.REPORTDATE} <= nthlargest(3,{WORKORDER.REPORTDATE})
        else {WORKORDER.REPORTDATE} <= nthlargest(Count(3,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
            else if shared stringvar rowsuppress_sv = '4' then  
            (if (Count({WORKORDER.REPORTDATE}) >= 4) then
            {WORKORDER.REPORTDATE} <= nthlargest(4,{WORKORDER.REPORTDATE})
            else {WORKORDER.REPORTDATE} <= nthlargest(Count(4,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
                else if shared stringvar rowsuppress_sv = '5' then  
               (if (Count({WORKORDER.REPORTDATE}) >= 5) then
                {WORKORDER.REPORTDATE} <= nthlargest(5,{WORKORDER.REPORTDATE})
                else {WORKORDER.REPORTDATE} <= nthlargest(Count(5,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
                    else 1=0
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 24209710
Since COUNT produces a number you can't use NthLargest on it.

if shared stringvar rowsuppress_sv = '1'then
   {WORKORDER.REPORTDATE} <= nthlargest(1,{WORKORDER.REPORTDATE})
    else if shared stringvar rowsuppress_sv = '2'then
    (if (Count({WORKORDER.REPORTDATE}) >= 2) then
    {WORKORDER.REPORTDATE} <= nthlargest(2,{WORKORDER.REPORTDATE})
    else {WORKORDER.REPORTDATE} <= nthlargest(2,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
        else if shared stringvar rowsuppress_sv = '3'then
        (if (Count({WORKORDER.REPORTDATE}) >= 3) then
        {WORKORDER.REPORTDATE} <= nthlargest(3,{WORKORDER.REPORTDATE})
        else {WORKORDER.REPORTDATE} <= nthlargest(3,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
            else if shared stringvar rowsuppress_sv = '4' then  
            (if (Count({WORKORDER.REPORTDATE}) >= 4) then
            {WORKORDER.REPORTDATE} <= nthlargest(4,{WORKORDER.REPORTDATE})
            else {WORKORDER.REPORTDATE} <= nthlargest(4,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
                else if shared stringvar rowsuppress_sv = '5' then  
               (if (Count({WORKORDER.REPORTDATE}) >= 5) then
                {WORKORDER.REPORTDATE} <= nthlargest(5,{WORKORDER.REPORTDATE})
                else {WORKORDER.REPORTDATE} <= nthlargest(5,{WORKORDER.REPORTDATE}),{WORKORDER.REPORTDATE}))
                    else 1=0

mlmcc
0
 

Author Comment

by:washvt
ID: 24262738
Since COUNT produces a number you can't use NthLargest on it.

Could you please demonstrate where to take the "NthLargest" out of the formula.  Thank you.

if shared stringvar rowsuppress_sv = '1'then
   {WORKORDER.REPORTDATE} <= nthlargest(1,{WORKORDER.REPORTDATE})
    else if shared stringvar rowsuppress_sv = '2'then
    (if (Count({WORKORDER.REPORTDATE}) >= 2) then
    {WORKORDER.REPORTDATE} <= nthlargest(2,{WORKORDER.REPORTDATE})
    else {WORKORDER.REPORTDATE} <= nthlargest(2,{WORKORDER.REPORTDATE}),   {WORKORDER.REPORTDATE}))
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 24264864
That should be working

mlmcc
0
 

Author Comment

by:washvt
ID: 24265030
When I check the formula - I'm getting "The ) is missing - at the comma between - Thank you.

nthlargest(2,{WORKORDER.REPORTDATE}),   {WORKORDER.REPORTDATE}))

else {WORKORDER.REPORTDATE} <= nthlargest(2,{WORKORDER.REPORTDATE}),   {WORKORDER.REPORTDATE}))
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 24265463
Just saw the issue

if shared stringvar rowsuppress_sv = '1'then
   {WORKORDER.REPORTDATE} <= nthlargest(1,{WORKORDER.REPORTDATE})
    else if shared stringvar rowsuppress_sv = '2'then
    (if (Count({WORKORDER.REPORTDATE}) >= 2) then
    {WORKORDER.REPORTDATE} <= nthlargest(2,{WORKORDER.REPORTDATE})
    else {WORKORDER.REPORTDATE} <= nthlargest(2,{WORKORDER.REPORTDATE})
        else if shared stringvar rowsuppress_sv = '3'then
        (if (Count({WORKORDER.REPORTDATE}) >= 3) then
        {WORKORDER.REPORTDATE} <= nthlargest(3,{WORKORDER.REPORTDATE})
        else {WORKORDER.REPORTDATE} <= nthlargest(3,{WORKORDER.REPORTDATE})
            else if shared stringvar rowsuppress_sv = '4' then  
            (if (Count({WORKORDER.REPORTDATE}) >= 4) then
            {WORKORDER.REPORTDATE} <= nthlargest(4,{WORKORDER.REPORTDATE})
            else {WORKORDER.REPORTDATE} <= nthlargest(4,{WORKORDER.REPORTDATE})
                else if shared stringvar rowsuppress_sv = '5' then  
               (if (Count({WORKORDER.REPORTDATE}) >= 5) then
                {WORKORDER.REPORTDATE} <= nthlargest(5,{WORKORDER.REPORTDATE})
                else {WORKORDER.REPORTDATE} <= nthlargest(5,{WORKORDER.REPORTDATE)
                    else 1=0

mlmcc
0
 

Author Closing Comment

by:washvt
ID: 31569077
Thank you!  
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question