Quantcast
Channel: SCN : All Content - Data Services and Data Quality
Viewing all articles
Browse latest Browse all 4013

Data Insight Aggregate functions

$
0
0

Trying to figure out how to use the aggregate functions, specifically MIN but there are other cases I want to try with the SUM as well.

 

For the MIN example, it is not clear how to use Data Insight to compare a aggregated value row by row.  I have tried creating a view as well as adding the logic into a rule both without luck.  There does not appear to be any use cases online that explore the complex functionality of Data Insight in this way.

 

Example 1, find the lowest number value over multiple rows for one entity and calculate whether this is acceptable.  Some jimmied up data is below

 

Customer  Type  Value

1               A        1

1               A        2

1               A        3

2               A        3

2               A        5

2               I         1

3               I         1

3               I         1

 

So in this case, the data exists across multiple tables.  I want to find all customers that have a value of 1 that are A for active and exclude the other rows.  So in this case, customer 2 would fail once as it did not have a 1.

 

What I tried:

1. using MIN and decode logic in a view and then building a basic rule (did not work).

2. using complex SQL logic in the rule.  For example:

 

BEGIN

$Select_SQL = replace_substr('select Customer_No, min(Value) from Customer_Table

where Type=\'A\' AND Customer = \'XXX\' ', 'XXX', $Customer_Parameter);

 

$Value= SQL('Connection', $Select_SQL);

BEGIN
IF ($Value ='1')
BEGIN
RETURN TRUE;
END
ELSE
RETURN FALSE;
END
END

 

The logic for the rule checks out but it does not complete.  Now when I calculate the more complex version of this in SQL it works but when in a rule the syntax is unclear.  So I am not sure if this is doing a total of all rows or for each customer.  When I have the Customer_No from the select then the rule task fails.

 

Has anyone tried anything complex like this?

 

The other use case is around summing a total of purchase orders for a supplier and determining whether this is in certain range bands based on defined amounts.  I think the same use case applies to both.


Viewing all articles
Browse latest Browse all 4013

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>