BAQ Slow! Performance issue

Hi everyone
Happy Halloween!

I’ve been working on a Customer OTIF BAQ which pulls almost 5000 records based on all shipments sent over the last 100 days.

What I want to do is roll all the results up to count records of how many late, how many on time and calculate a percentage by week.

I have the design and it produced all figures correctly BUT- Its REALLY SLOW

‘Dataset’ is the original query which produces 4744 records.


I then added 3 inner subqueries - which all each have the ‘dataset’ and a count for 'On Time, 2nd subquery count of ‘All Recs’ and 3rd subquery count for ‘Late’.

The TOP LEVEL the adds all these subqueries and joins them together and calculates the percentage on time, percentage late by week num

image
The result is exactly what I want so I can graph in a dashboard however it takes a heck of a long time

Is there any way I can rewrite this to run quicker?

Many thanks

Carla

Can you attach your BAQ? How long does it currently take to run? Have you tried doing your calculations in 1 subquery rather than 3?

I cant work out how to coutn records on one dataset for different field contents ie Count records where OnTime = ‘1.OnTime’ and Count records where OnTime= ‘2.Late’

I assumed I needed multiple datasets to do that record counting

BAQ attached thankyouCLW_OTIFCust.baq (65.8 KB)

Try adding a criteria to one of the tables where Company = CurrentCompany.
It simplifies the query that is sent to SQL and is often helpful when order or customer tables are included and the salesperson security is applied behind the scenes.

I gotcha, you can do it with the same data set with a “CASE…WHEN” statement in your calc field with the count statement. I think doing this would really help your run time since it would reduce the number of tables. I think another big thing affecting your time are the joins on calculated fields, which this would fix. I unfortunately don’t have all the UD fields that you do so I can’t test with your query, but I threw a little example together that shows how CASE WHEN COUNT could work for you.

The BAQ just counts the number of stock / nonstock parts per product group, which could relate to on-time / late shipments per week in your BAQ.

Subquery 1 - Initial grouping / count
Subquery 2 - Final grouping to get counts on the same line
Subquery 3 - test query to verify counts in subquery 2 are correct

I like to move the Top Level query around to help visualize what happens.
CASEWHENTEST.baq (27.5 KB)

Thankyou but I cant import into baq:

image001.png

image325026.png

image745634.png

image711792.png

image209680.png

image079666.png

Which version of ICE are you on?

3.1.400.0
:blush:

image325026.png

image745634.png

image711792.png

image209680.png

image079666.png

Ok, as per another post I changed the ICE version on the BAQ. Apparently still not guaranteed to work, but if that’s the case I can snip a few screenshots.

CASEWHENTEST.baq (27.5 KB)