Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello all!
We have two tables (see attached qvw):
Dates:
LOAD * INLINE
[date_c, month
2009-11-1, 11
2009-11-1, 11
2009-11-2, 11
2009-12-1, 12
2009-12-1, 12
];
Orders:
LOAD * INLINE
[date_c, customer, ordercnt
2009-11-1, first, 1
2009-11-1, second, 1
2009-11-2, first, 1
2009-12-1, first, 1
2009-12-1, second, 1
];
And we have text object with formula: =Sum(ordercnt)/Count(Distinct customer)
In November the result is 1,5. This is correct. (We have 3 orders and two customers).
In December the result is 1. This is correct. (We have 2 orders and two customers).
Without selections result is 2,5. This is correct too. (We have 5 orders and only two customers).
But i need somthing different. I need 1,25 in result expresion. (1,5+1)/2 (Average value of this expression in two months)
Thnx
Try this:
=(Sum(ordercnt)/Count(Distinct customer))/Count(DISTINCT month)
Try this:
=(Sum(ordercnt)/Count(Distinct customer))/Count(DISTINCT month)
hi
replace your expression in the text box with
=avg(aggr(Sum(ordercnt)/Count(Distinct customer) , month))
regards
jj
I was putting that together right before you posted it; the AGGR function is the best way to solve this.
Thanks Jason, I made some progress
Thanks!
But i change rules at play)
Lets add one column and one row to Orders table:
Orders:
LOAD * INLINE
[date_c, customer, region, ordercnt
2009-11-1, first, a, 1
2009-11-1, second, b, 1
2009-11-2, first, a, 1
2009-11-2, third, a, 1
2009-12-1, first, a, 1
2009-12-1, second, b, 1
];
hi
i think it's just a problem of definition of your average.
with the first formula :
(6 orders / 3 customer ) / (2 month) = 1 => it's the average number of orders by customer and by month
with the second formula
( ( 4 orders / 3 customers) in november + ( 2 orders / 2 customers) in december) / 2 = 0.5 * ( 4/3 + 1) = 1.17
=> it's the month-average of the number of orders by customer.
jj