Alteryx Designer Desktop Discussions

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

Sum up the values of dynamic incoming columns

Brayndasilva
7 - Meteor

Hi,

 

I am using the CrossTab tool to process a bunch of data to one group per row. Let's take invoices as an example here. I have multiple rows containing information on how my invoices are built up. The number of rows to an invoice vary. These translate to the unique attributes of an invoice, but also other values that I don't need to take in account.

 

The result of my CrossTab tool looks something like:

Brayndasilva_1-1638175519135.png

 

What would be the most efficient way to sum up all 'attr_' values dynamically per invoice? Some invoices may have 4 attributes that built up the total, others 10 or more. 

 

4 REPLIES 4
afv2688
16 - Nebula
16 - Nebula

Hello @Brayndasilva ,

 

Do you mean something like this?

 

Untitled.png

 

Regards

Brayndasilva
7 - Meteor

Hey @afv2688,

 

Thanks for your reply!

 

That looks good, but for my use case I would need a total column per invoice/row. I'll add that detail to my original post

afv2688
16 - Nebula
16 - Nebula

Oh alright, sorry my mistake 🙂

 

Here I got you an example and what I think would be the easiest way to remove values to not be taken into account for the calculations.

 

Regards

Brayndasilva
7 - Meteor

Thanks, your solution works fine!

 

With the help of the R tool I was able to achieve the same with a few lines of code:

library(dplyr)
data <- read.Alteryx("#1", mode="data.frame") %>%
  select('invoice_n',contains("attr_"))

data[is.na(data)] <- 0
data$total <- rowSums(data[2:ncol(data)])

write.Alteryx(data, 1)

 

Labels