Solved

NthLargest

Posted on 2009-04-10
12
415 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 100

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 100

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
Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

 

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 100

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 100

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 100

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 100

Accepted Solution

by:
mlmcc earned 500 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

752 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