28 Replies Latest reply: Sep 12, 2017 3:12 PM by rahul singh

# Class Function with Max Interval?

I am using a class function that shows =class(WORKFLOW_DURATION,30,WORKFLOW_DURATION) .

I want the largest interval to show >120. Rather than 120 - 150, etc... How can I do this?

Thanks,

Cassandra

• ###### Re: Class Function with Max Interval?

May be this:

=If(WORKFLOW_DURATION <= 120, Class(WORKFLOW_DURATION, 30, WORKFLOW_DURATION), '>120')

• ###### Re: Class Function with Max Interval?

Thanks, Sunny. Then how would I sort it so that >120 comes after the other intervals?

• ###### Re: Class Function with Max Interval?

Try this:

Dual(If(WORKFLOW_DURATION <= 120, Class(WORKFLOW_DURATION, 30, WORKFLOW_DURATION), '>120'), Class(WORKFLOW_DURATION, 30, WORKFLOW_DURATION))

• ###### Re: Class Function with Max Interval?

That doesn't look quite right...

• ###### Re: Class Function with Max Interval?

Oh I understand why it is doing this:

May be try this:

Dual(

If(WORKFLOW_DURATION <= 120, Class(WORKFLOW_DURATION, 30, WORKFLOW_DURATION), '>120'),           If(WORKFLOW_DURATION <= 120, Class(WORKFLOW_DURATION, 30, WORKFLOW_DURATION), 150)

)

• ###### Re: Class Function with Max Interval?

Thanks, Sunny!

• ###### Re: Class Function with Max Interval?

Any idea why the interval shows 3 numbers? What does the middle number mean - an average or something?

• ###### Re: Class Function with Max Interval?

I think you have specified the x to be replaced by WORKFLOW_DURATION

Class(WORKFLOW_DURATION, 30, WORKFLOW_DURATION), '>120')

Change the third argument to make it something static (QlikView ‒ class - script and chart function)

• ###### Re: Class Function with Max Interval?

For some reason, I am getting the same REQUEST_ID counted multiple times and not sure why. I would only expect it to be counted once in 60-90 since the duration is 70 days. Any idea? I am thinking I need to use something like this: =class(Sum(total WORKFLOW_DURATION),30)

Dimensions:

• dPgmPm (a group)
• =DualIf(WORKFLOW_DURATION <= 120, Class(WORKFLOW_DURATION, 30), '>120'),  If(WORKFLOW_DURATION <= 120, Class(WORKFLOW_DURATION, 30), 120) )
• =if(match(CUR_WORKFLOW_STEP_NAME,'Project Initiation and Design', 'Project Quality Review', 'Planning', 'Implementation', 'Close Out')>0,CUR_WORKFLOW_STEP_NAME,null())

Expression: count(DISTINCT REQUEST_ID)

• ###### Re: Class Function with Max Interval?

Can you share a sample?

• ###### Re: Class Function with Max Interval?

I am seeing just one bar for the selection you have in your application.

• ###### Re: Class Function with Max Interval?

If you Clear the selections, however, now the intervals don't look right.

If you look at the expression I am using, it is now Dual(If(WORKFLOW_DURATION <= 120, Class(Sum(total WORKFLOW_DURATION), 60), '>120'),
If(WORKFLOW_DURATION <= 120, Class(Sum(total WORKFLOW_DURATION), 60), 120))

• ###### Re: Class Function with Max Interval?

Create the Buckets in the script with IntervalMatch function.

• ###### Re: Class Function with Max Interval?

Do you have a reference for that?

• ###### Re: Class Function with Max Interval?

Can you point out what isn't working? May be tell us what selections to make and what are the expected result based on those selections

• ###### Re: Class Function with Max Interval?

if you select REQUEST_ID 182921, you will see two versions of the chart. The top one shows two buckets for one request (not sure why). The second chart looks correct with the  60-120 bucket compared to the data on the bottom showing 101 business days.

However, if you clear the selections, you will see the buckets for the second chart no longer reflect 0-60, 60-120 and >120. This is why I was playing with the Class(Sum(total))) in the expression...

Does that help? Sorry for the confusion.

• ###### Re: Class Function with Max Interval?

Based on the REQUEST_ID selection, there are two rows of data one is between 0 and 60 and other is between 60 and 120. That is why you see two bars. Would you want to add them together when you create classes?

• ###### Re: Class Function with Max Interval?

I don't see two rows of data...

• ###### Re: Class Function with Max Interval?

Forgot to attach the screen shot

• ###### Re: Class Function with Max Interval?

hi Sunny,

I have something similar

I have to  show po amount across various supplier in date bracket

maxDate-- is the date user selects and Orderentry is the po date

Dual(

If(num(\$(vMaxDate))-num(OrderEntryDate) <= 120, Class(num(\$(vMaxDate))-num(OrderEntryDate), 30, 'Age'), '>120'),

If(num(\$(vMaxDate))-num(OrderEntryDate) <= 120, Class(num(\$(vMaxDate))-num(OrderEntryDate), 30, num(\$(vMaxDate))-num(OrderEntryDate)), 150)

)

The above is showing error in calculated dimension

regards,

Rahul

• ###### Re: Class Function with Max Interval?

Would you be able to share a sample to see the issue?

• ###### Re: Class Function with Max Interval?

Hi This is the code I am using:

MasterCalendar:

LOAD *,Month(date1) as Months,Year(date1) as Years;

AutoGenerate 1

While Date('01/01/2015' +IterNo()-1) <= Today();

PO:

inline

[

supplier,OrderEntryDate,Amount

A,'12-JUN-16',100

B,'13-JUL-17',200

C,'1-JAN-15',30,

];

//WHEN A USER SELECTS A DATE FROM CALENDAR THE AGE IS CALCULATED BY SUBTRACTING ORDERENTRYDATE AND CALENDAR DATE

//THAT AGE IS PUT IN A BUCKET FOR WHICH I THOUGHT OF USING A CLASS FUNCTION

SUPPLIER 0-30     31-60     61-90     >90

A                  100

B                              200

Something like this

regards

• ###### Re: Class Function with Max Interval?

Hi sunny,

aggr(

if(num(\$(vMaxDate))-num(OrderEntryDate)<0,num('Days<0'),

if(num(\$(vMaxDate))-num(OrderEntryDate)>=0 and

(num(\$(vMaxDate))-num(OrderEntryDate))<=180,

(class(num(\$(vMaxDate))-num(OrderEntryDate),30,'Age')),

//if(num(\$(vMaxDate))-num(OrderEntryDate)>180,

num('>180 Days'))),company,Supplier,PurchaseOrder)

here I am getting a bracket as 180-210 days which should not be the case as I am restricting it after 180 days as >180 and nor it is able to sort the value

• ###### Re: Class Function with Max Interval?

See if this is what you want?

• ###### Re: Class Function with Max Interval?

This looks right. Testing it out in other situations now. Thanks again!

• ###### Re: Class Function with Max Interval?

Hi This is the code I am using:

MasterCalendar:

LOAD *,Month(date1) as Months,Year(date1) as Years;

AutoGenerate 1

While Date('01/01/2015' +IterNo()-1) <= Today();

PO:

inline

[

supplier,OrderEntryDate,Amount

A,'12-JUN-16',100

B,'13-JUL-17',200

C,'1-JAN-15',30,

];

//WHEN A USER SELECTS A DATE FROM CALENDAR THE AGE IS CALCULATED BY SUBTRACTING ORDERENTRYDATE AND CALENDAR DATE

//THAT AGE IS PUT IN A BUCKET FOR WHICH I THOUGHT OF USING A CLASS FUNCTION

SUPPLIER 0-30     31-60     61-90     >90

A                  100

B                              200

Something like this

regards