- Posts: 27
Grouping and Summing with If Condition
- Gennaro
- Topic Author
- Offline
- User
Less
More
13 years 11 months ago #2071
by Gennaro
Grouping and Summing with If Condition was created by Gennaro
Attachments:
Please Log in or Create an account to join the conversation.
- FlowHeater-Team
- Offline
- Admin
13 years 11 months ago #2072
by FlowHeater-Team
Best wishes
Robert Stark
Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
Replied by FlowHeater-Team on topic Re:Grouping and Summing with If Condition
Hi Gennaro,
That's a really nice challenge Yes, FlowHeater can handle it, but it’s a bit tricky. I have made an example to demonstrate this. Please have a look to the attachment "grouping_and_summing_with_condition.zip"
In the example I'm used the TextFile Adapter for READ (import.csv) and WRITE (output.csv). You can it simple to port to use it with the Excel Adapter . The TextFile Adapter is just a bit faster.
The example used
First the If-Then-Else Heater checks the field "type" with the criteria "in". If the value match (=in) the string append heater appended the fields “code” and "type" and pass it to the GroupBy Heater. If the criteria don’t match the AutoID Heater generates a new number (+1) and passes it to the GroupBy Heater. The GroupBy Heater only grouping rows together if the same consecutive equally value are passed! In the else case there are never the same value because the AutoID Heater, that’s the trick. The Additions Heater just summing the incoming values by the group.
That's a really nice challenge Yes, FlowHeater can handle it, but it’s a bit tricky. I have made an example to demonstrate this. Please have a look to the attachment "grouping_and_summing_with_condition.zip"
In the example I'm used the TextFile Adapter for READ (import.csv) and WRITE (output.csv). You can it simple to port to use it with the Excel Adapter . The TextFile Adapter is just a bit faster.
The example used
- two Additions Heater with data aggregation to build the sum
- one If-Then-Else Heater for the condition
- one GroupBy Heater for grouping data
- one String Append Heater to builds the grouping criteria
- one AutoID Heater , that’s the trick
First the If-Then-Else Heater checks the field "type" with the criteria "in". If the value match (=in) the string append heater appended the fields “code” and "type" and pass it to the GroupBy Heater. If the criteria don’t match the AutoID Heater generates a new number (+1) and passes it to the GroupBy Heater. The GroupBy Heater only grouping rows together if the same consecutive equally value are passed! In the else case there are never the same value because the AutoID Heater, that’s the trick. The Additions Heater just summing the incoming values by the group.
Attachment grouping_and_summing_with_condition.zip not found
Best wishes
Robert Stark
Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
Attachments:
Please Log in or Create an account to join the conversation.
- Daniel
- Offline
- User
Less
More
- Posts: 5
6 years 4 weeks ago #3483
by Daniel
Replied by Daniel on topic Re:Grouping and Summing with If Condition
Hi, I am trying to do something similar. Would be grateful if you could repost this solution so I could view it in the latest version of Flowheater.
Also, I can't figure out how to trim a string to contain just the first three words, that are separated by spaces.
Example
Read side:
"foo bar foo bla bla blah"
Write side:
"foo bar foo"
Thank you! This program is awesome!
Also, I can't figure out how to trim a string to contain just the first three words, that are separated by spaces.
Example
Read side:
"foo bar foo bla bla blah"
Write side:
"foo bar foo"
Thank you! This program is awesome!
Please Log in or Create an account to join the conversation.
- FlowHeater-Team
- Offline
- Admin
6 years 4 weeks ago #3484
by FlowHeater-Team
Best wishes
Robert Stark
Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
Replied by FlowHeater-Team on topic Re:Grouping and Summing with If Condition
Hi Daniel,
Please find attached the converted example, this works now with the current version 4.1.3.1. In the ZIP archive you´ll find also a short example how to split just the first three words of a string. For this you need three String Split Heater and on String Append Heater to append the first three words to one string again.
Please find attached the converted example, this works now with the current version 4.1.3.1. In the ZIP archive you´ll find also a short example how to split just the first three words of a string. For this you need three String Split Heater and on String Append Heater to append the first three words to one string again.
Best wishes
Robert Stark
Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
Attachments:
Please Log in or Create an account to join the conversation.
Time to create page: 0.309 seconds