Solved

NthLargest

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

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now