If you were going to do this in SQL it would be pretty straight forward. You would sum up the total sales per customer, and then only return those customers having total sales of more than $10,000.
eg. SELECT customer, sum(salesamount) FROM sales GROUP BY customer HAVING sum(salesamount) > 10000;
Now Data Services has the very useful Query transform that does nearly everything we need, but not quite.
If we have a look at the tabs available to us in the query transform we have a GROUP BY tab, but no HAVING tab.
So how do we get around this?
Well the first step is to create a query the gets the total sales per customer, grouping on customer name, and summing the sales amount.
Then pass the results from that query into a second query that filters down the results based on the results from the first query.
Not exactly rocket science, which is why I wish that SAP would just add the HAVING clause into the query transform. There are two main reasons why having the clause in the transform would be nice:
- It would make data flows a bit neater. When you have a massive collection of transforms in a complex data flow, the last thing you need is extra transforms on the screen just to carry out a fairly trivial task.
- The HAVING clause does not get pushed down. Take a look at the SQL produced by the above data flow:
So if any-one from SAP is reading this blog, please give us a HAVING clause.
I liked you efforts & explanation Sean. I too have one http://dwhnotes.com/data-integrator Please go thru it and let me know your comments
ReplyDeleteCheers,
Sudheer
Awesome Explanation.
ReplyDeleteThanks,
NAYAN GUPTA