Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Pivot with aggr function

Hello Everybody,

I have a Table like the one below:

customercall
A1
B1
C1
D1
C1
D1
A1
B1
C1
D1


Of course the pivot table is like this:

CustomerCount of call
A2
B2
C3
D3


I would like to have from the first table the following result:

Count of customerCount of call
22
23


Coul you help me?

Thank you in advance, regards.

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

You can use the AGGR function to do it.

Create a dimension as aggr( sum( call ) , customer ) it's the number of call by customer

Create an expression with count(distinct customer)

after that it'd be easier do use filter.

jj

View solution in original post

4 Replies
Anonymous
Not applicable
Author

Hi rapozzatir,

You can aggregate the data in the script like this:


T1:
LOAD * INLINE [
Customer, Call
A, 1
B, 1
C, 1
D, 1
C, 1
D, 1
A, 1
B, 1
C, 1
D, 1
];
T2:
Load
Customer,
sum(Call) as CallCount
resident T1
group by Customer;
join
Load
CallCount,
count(Customer) as CustomerCount
resident T2
group by CallCount;


Then you have your CustomerCount and CallCount as in the posted example.

Not applicable
Author

Thank you very much Johannes, it works!!

Just one more question: the filters do not work anymore with the new pivot. How can I use some variables to filter output data?

Thank you very much,

Roberto

Not applicable
Author

Hi,

You can use the AGGR function to do it.

Create a dimension as aggr( sum( call ) , customer ) it's the number of call by customer

Create an expression with count(distinct customer)

after that it'd be easier do use filter.

jj

Not applicable
Author

Perfect!! Thank you very much.

regards,

Roberto