3 Replies Latest reply: Dec 20, 2015 7:14 PM by Ignacio Garribia

# How to calculate number of orders with errors in qlik sense

Hello Everyone! I need your help!

I have to calculate the number of orders with errors. An error ocurrs when the quantity of Items ordered is different from the quantity of items shipped.

I have the fields: Order ID, Shipment ID and Product ID

and calculated measures:( in master items):

Quantity of Items ordered( ((COUNT([ProductID]))/COUNT(DISTINCT(OrderID))

Quantity of Items Shipped ((COUNT([ProductID]))/COUNT(DISTINCT(ShipmentID))

Numbers of different Orders ( Count(Distinct(OrderID)

How can I calculate the number different orders with errors?

Thank you very much for your help.

• ###### Re: How to calculate number of orders with errors in qlik sense

Maybe Count({<OrderID={"=Count(ProductID)<>Count(ShipmentID)"}>}Distinct OrderID).

But this assumes that:

• Only one unit of a product is ordered per order
• In a single shipment only one product per order is shipped.

If these assumptions are not correct then you need to provide more information. In that case please post a small qlikview document that illustrates the problem.

• ###### Re: How to calculate number of orders with errors in qlik sense

Hello Gysbert! Thank you very much for your help. It works perfectly this way:

Count({<OrderID={"=(COUNT([ProductID]))/COUNT(DISTINCT(OrderID))<>(COUNT([ProductID]))/COUNT(DISTINCT(ShipmentID))"}>}Distinct OrderID)

I had to make some chances because I have multiple items in each order and shipment.

Again, thank you very much,

• ###### Re: How to calculate number of orders with errors in qlik sense

Hi,

Try like this

=Sum(Aggr(If(Sum(OrderedItems) <> Sum(ItemsShipped), 1, 0), OrderID))

OR

Count({<OrderID={"=Sum(OrderedItems)<>Sum(ItemsShipped)"}>}Distinct OrderID)

Hope this helps you.

Regards,

Jagan.