Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

How to sum multiple rows with a conditional statement

mmad
5 - Atom

Hello all,

 

I have a data problem wherein I need to sum for each month all negative values and paste the values in a new row and all positive values and paste the values in an other row. Here is my sample dataset:

 

GroupMonth1Month2Month3
A-583
B421
C-10-50
D2-2-1

 

The result would be

GroupMonth1Month2Month3
Negative-15-7-1
positive6104

 

My problem is that i need to apply this formula on several columns (more than 100). Without a conditional statement "IF month value > 0", I would have used a Summarize tool. But in my case, I d'ont see how to solve my problem.

 

Could you please help me on this?

 

Thanks

 

5 REPLIES 5
Kenda
16 - Nebula
16 - Nebula

Hi @mmad!

 

I think the key here is that you want to Transpose your data first. From here, it is easy to sum all of your columns. You will just first want to Filter any numbers that are less than 0. Then use a Summarize to group by the month name and sum the values. Lastly, use a Cross Tab to get the data back in the right format, use a Formula tool to add your title field, and Union to get all of the results together. 

 

See the attached workflow for an example!

 

Capture.PNG

Thableaus
17 - Castor
17 - Castor

Hi @mmad 

 

Here's a solution with Cross-Tab tool:

 

GroupCrossTab.PNG

 

- Transpose your columns

- Formula Tool to apply negative and positive clause

- Cross-Tab Tool to summarize.

 

WF attached.

 

Cheers,

MarqueeCrew
20 - Arcturus
20 - Arcturus

@Kenda ,

 

After turning my monitor sideways, I like it :)

 

Cheers,


Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Kenda
16 - Nebula
16 - Nebula

Are @patrick_digan and I the only ones in the whole universe who do vertical?? 

tmlmark
7 - Meteor

@Kenda Yes 😁

Labels