Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Script Expression Error

Hey guys.

Im trying to find the on tme shipping % can anyone help me? this is my formula in script:

if(ShipDate-DueDate<=0,'On-Time','Late') as ShipmentStatus,

num(count(if(ShipDate-DueDate<=0,'On-Time','Late')'On-Time',/if(ShipDate-DueDate<=0,'On-Time','Late')'Late'),'#0%') as OnTime%

And this is the error:

error loading image

Please help me

1 Solution

Accepted Solutions
Not applicable
Author

Hi Blaze,

Let us say you want to calculate the OnTime Shipment %. You have some fields InvNo, InvDt, ShipDate, DueDate, InvAmount, InvQty.

INVOICE_DETAILS:

LOAD CustomerCode,

InvNo,

InvDt,

ShipDate,

DueDate,

InvAmount,

InvQty,

If( ShipDate - DueDate <= 0,'On Time', 'Late') AS ShipStatus

FROM INVOICE_DETAILS.xls;

In the graphs (front end), you can write the expressions

= COUNT(DISTINCT If( ShipStatus = 'On Time', InvNo )) / COUNT( DISTINCT InvNo)

Let us say that you have 100 invoices out of which 60 was delievered on time and 40 was late delievery.

This expression will give you 60%.

Hope, it would helpful for you.

Thanks & Regards,

Raj Kishor

View solution in original post

7 Replies
Not applicable
Author

anyone?

Not applicable
Author

Hi Blaze,

You could try use : count( {$<ShipmentStatus = {"On-Time"}>} value ) for the On-Time Count

Then another expression for Late : count( {$<ShipmentStatus = {"Late"}>} value )





Not applicable
Author

Hey Xena.

Thanks for the reply. I tried :

=count( {$<ShipmentStatus = {"On-Time"}>})/count( {$<ShipmentStatus = {'Late'}>})

but it doesn't work.I need to take the total shipments made, whether they were late or not, and then divide by the number of late shipments to work out the On-time %. It also needs to be done in the script. Have u maybe got any other ideas? Thanks so much for your help i really appreciate it.

Not applicable
Author

Hi Blaze,

Let us say you want to calculate the OnTime Shipment %. You have some fields InvNo, InvDt, ShipDate, DueDate, InvAmount, InvQty.

INVOICE_DETAILS:

LOAD CustomerCode,

InvNo,

InvDt,

ShipDate,

DueDate,

InvAmount,

InvQty,

If( ShipDate - DueDate <= 0,'On Time', 'Late') AS ShipStatus

FROM INVOICE_DETAILS.xls;

In the graphs (front end), you can write the expressions

= COUNT(DISTINCT If( ShipStatus = 'On Time', InvNo )) / COUNT( DISTINCT InvNo)

Let us say that you have 100 invoices out of which 60 was delievered on time and 40 was late delievery.

This expression will give you 60%.

Hope, it would helpful for you.

Thanks & Regards,

Raj Kishor

Not applicable
Author

You can add this small bit into your script.

Not applicable
Author

Hey Raj.

Thanks for the reply. I understand what you mean about the Invno, etc. I used this:

= COUNT(DISTINCT If( ShipmentStatus = 'On Time', PurchaseOrderNumber )) / COUNT( DISTINCT PurchaseOrderNumber)

Where PurchaseOrderNumber was the Order number and it still gives me -?

Any Ideas?

Not applicable
Author

Hey Raj.

Your Formula worked. It was on my side. I wrote 'On Time' instead of 'On-Time'. My bad 🙂

Correct formula is this:

=num(COUNT(DISTINCT If( ShipmentStatus = 'On-Time', PurchaseOrderNumber ))/COUNT( DISTINCT PurchaseOrderNumber),'##,0%')

Thanks again for the help guys.