Skip to main content
Solved

How to Use Summary Output from Statistics Calculator as part of calculation


Forum|alt.badge.img

Hello,

This should be a very simple thing, but I just can't figure out how to do it!

I want to append two tables together (Tables 1 & 2), both with very similar attributes, but I want to use the ID from Table 1 as the official Primary Key, and then get the highest number from that PK and increment upwards to create new PK values for the Table 2 appended values. I can get the maximum value from Table 1 using StatisticsCalculator, but I can't for the life of me work out how to use that value in the creation of the new Primary Key.

I've been trying to do a conditional value calculation in Attribute Manager, something like, if Table 1 ID has a value, then PK = Table 1 ID, else use MaxValue from StatisticsCalculator and sum it with @sum(@double(@Count()),1.0) to increment up. But it's not working.

Any ideas greatly appreciated!

Thank you!

Katrina

Best answer by mark2atsafe

I tried to make something and it came out pretty much like @itay and @gio said. StatisticsCalculator, FeatureMerger, Counter. Like this:

 

View original
Did this help you find an answer to your question?

4 replies

itay
Supporter
Forum|alt.badge.img+17
  • Supporter
  • January 3, 2019

Hi @katrinaopperman,

If what you require is an increment on the highest value from table 1 ( max value from statistics calculator) then you can use a Counter to add to that value.

Alternatively if you are writing to a database, you can set up a sequence on the database starting from the max value and let de database take care of the PK increment.

Hope this helps,

Itay


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • January 3, 2019

@katrinaopperman

 

Hi.

 

The max. value you acquired from the Statistics Calculator summary output should be merged to the data from table 2.

So either you use a unconditional merger (requestor Key=Suplier Key, I usually simply do 1=1)

Or use, if the process stream allows it a variable setter and retriever).

The value is then related from table1 stats to table2.

Now u can (re)calculate the PK for table2. You can indeed use a counter and set it to start at the (related) max value +1

 


mark2atsafe
Safer
Forum|alt.badge.img+44
  • Safer
  • Best Answer
  • January 3, 2019

I tried to make something and it came out pretty much like @itay and @gio said. StatisticsCalculator, FeatureMerger, Counter. Like this:

 


Forum|alt.badge.img
mark2atsafe wrote:

I tried to make something and it came out pretty much like @itay and @gio said. StatisticsCalculator, FeatureMerger, Counter. Like this:

 

Brilliant! Thank you @Mark2AtSafe, @gio, and @itay! That worked perfectly!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings