Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Olá!
Tenho 7 Categorias de produtos onde em cada categoria é armazenado o valor de venda deste produto(podendo variar).
| Cat1 | Cat2 | Cat3 | Cat4 | Cat5 | Cat6 | Cat7 |
|---|---|---|---|---|---|---|
| 2834 | 3211 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 34320 | 0 | 3211 | 6434 | 6456 |
| 9234 | 0 | 0 | 0 | 4361 | 643 | 0 |
Usando CrossTable as transformo em um Campo e o valor em outro campo, até ai beleza.
O problema é que quando relaciono minhas vendas com essa categoria, é duplicado conforme exemplo:
| Categoria | Venda |
|---|---|
| Cat1 | Venda1 |
| Cat2 | Venda1 |
| Cat3 | Venda1 |
| Cat4 | Venda1 |
| Cat5 | Venda1 |
| Cat6 | Venda1 |
| Cat7 | Venda1 |
Sendo que para esta venda só exista valor na Cat1 e Cat2.
Alguém indica uma solução, por favor?
Caso ainda não tenha ficado claro, tento detalhar mais.
Agradecido desde já,
Alisson.
Olá,
Não sei como você fez, mas pode fazer assim:
TMP_Dados: CrossTable (Categoria,ValorVenda,1) LOAD * INLINE [ IDVenda, Cat1, Cat2, Cat3, Cat4, Cat5, Cat6, Cat7 1, 2834, 3211, 0, 0, 0, 0, 0 2, 0, 0, 34320, 0, 3211, 6434, 6456 3, 9234, 0, 0, 0, 4361, 643, 0 4, 10, 20, 30 ]; Dados: NoConcatenate Load * Resident TMP_Dados Where IsNum(ValorVenda); DROP Table TMP_Dados;
Resultado. Note que o IDVenda 4 possui apenas informação até a Cat3.
| IDVenda | Categoria | ValorVenda |
| 1 | Cat1 | 2834 |
| 1 | Cat2 | 3211 |
| 1 | Cat3 | 0 |
| 1 | Cat4 | 0 |
| 1 | Cat5 | 0 |
| 1 | Cat6 | 0 |
| 1 | Cat7 | 0 |
| 2 | Cat1 | 0 |
| 2 | Cat2 | 0 |
| 2 | Cat3 | 34320 |
| 2 | Cat4 | 0 |
| 2 | Cat5 | 3211 |
| 2 | Cat6 | 6434 |
| 2 | Cat7 | 6456 |
| 3 | Cat1 | 9234 |
| 3 | Cat2 | 0 |
| 3 | Cat3 | 0 |
| 3 | Cat4 | 0 |
| 3 | Cat5 | 4361 |
| 3 | Cat6 | 643 |
| 3 | Cat7 | 0 |
| 4 | Cat1 | 10 |
| 4 | Cat2 | 20 |
| 4 | Cat3 | 30 |
Don't worry, be Qlik.
Tonial