In case you missed the announcement: Alteryx One is here, and so is the Spring Release! Learn more about these new and exciting releases here!

Fórum

SOLUCIONADO

SUM sem Group by

GabrielStlz
Asteroide

Pessoal, eu gostaria de fazer o seguinte, no alteryx:

 

example:

I already read (this), but couldn't figure out a way to implement it to my specific problem. I know SUM() is an aggregate function and it doesn't make sense not to use it as such, but in this specific case, I have to SUM() all of the results while maintaining every single row.

Here's the table:

--ID-- --amount--
  1        23
  2        11
  3        8
  4        7

I need to SUM() the amount, but keep every record, so the output should be like:

--ID-- --amount--
  1        49
  2        49
  3        49
  4        49

I had this query, but it only sums each row, not all results together:

SELECT 
    a.id,
    SUM(b.amount)

FROM table1 as a 
JOIN table1 as b ON a.id = b.id
GROUP BY id

Without the SUM() it would only return one single row, but I need to maintain all ID's..

 

Eu tenho tentando fazer utilizando o summarize, porém não consigo trazer dessa forma

3 RESPOSTAS 3
marcusblackhill
12 - Quasar
12 - Quasar

Oi @GabrielStlz !

 

Você consegue fazer o mesmo pegando um summarize apenas para a coluna amount, ela vai retornar apenas 1 linha com o valor total, no caso, 49.

 

Depois disso, usa o append tool pra juntar a base original com o resultado do summarize e dentro do append ainda, vc retira o amount da base original e usa o amount que veio do summarize, assim você vai ter o mesmo resultado.

 

Espero ter ajudado! Se resolveu, não esquece de marcar como solução para fechar o tópico.

 

Abraço

GabrielStlz
Asteroide
Fiz dessa forma utilizando o append e funcionou perfeitamente! obrigado!
marcusblackhill
12 - Quasar
12 - Quasar

Aí sim @GabrielStlz !

 

Fico feliz que tenha conseguido!

Rótulos
Autores com maior número de soluções