Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

NthLargest

Posted on 2009-04-10
12
Medium Priority
?
420 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

 

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

704 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