Hi,
I have a simple tabular model. There is a sales table (2m rows), product table (80k rows), store table and a calendar.
In the product table there are 10k unique product codes. In the sales there are 160k docket numbers.
I can create an excel pivots which shows product codes, dockets and sales $. This returns a million combinations and it takes about a minute. Normally if we are looking at dockets we filter down to a store and date. Doing this reduces the returned results to only 300 rows. So it's an instant query.
I now add a calculation of % discount. This is discount $ / sales $. The query never finished. Even on the 300 rows. The calculation for this is:
IF('Sales'[Sales_Amount] = 0, BLANK() ,'Sales'[Discount_Amount] / 'Sales'[Sales_Amount])
I require the IF to handle the divide by zero errors. I've tried lots of combinations of this including using IFERROR and ISERROR and ISBLANK. All result in the same problem. The query becomes impossibly slow.
If i remove the test for zero the division is quick. If was to include the docket number and not the product code it was very fast, even if it returned 200k rows.
So my question is what is causing the IF statement to run so slowly when i use two dimensions that are relatively large. I have put filters on the excel pivot to cut the data volume down significantly but it looks like the IF statement must be getting calculated for every combination of docket and product, not just on those we have filtered down to.
These calculations at the summary level are brilliantly fast. But once we get to the really detailed levels they don't finish.
Regards.
Simon.