Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
What is the meaning of this expression?
Sum(Aggr(PD * Count(PD),PD))
If you have sample data for this, you can create the straight table with Dimension & above expression and try to break the expression to understand how it's working
first see, what PD * Count(PD) is giving,
then see, what Aggr(PD * Count(PD),PD) is giving
Finally see what is entire expression is giving
It will simple count PD and aggregate it with the same.
Example:
Here 1 has occurred twice , so its 1*2=2
and 2 has occurred once so its 2*1=2
# has occurred twice so, 3*2=6
and so on:
LOAD * INLINE [
PD
1
2
3
4
1
3
];
It will simply count the PD and multiply with its count.
If you have sample data for this, you can create the straight table with Dimension & above expression and try to break the expression to understand how it's working
first see, what PD * Count(PD) is giving,
then see, what Aggr(PD * Count(PD),PD) is giving
Finally see what is entire expression is giving
aggr statement is similar to sql group by.. if you are familiar with sql.
PD * Count(PD) seems to be wrong..
select PD,Count(Your Field)
group by (PD)
hth
Sasi
This looks like a more complex (and less efficient) way to compute Sum(PD). For example, with this load script:
LOAD * INLINE
[
PD
.1
.1
.1
.2
.2
.3
.3
];
Sum(Aggr(PD * Count(PD), PD)) = 3 * .1 + 2 * .2 + 2 * .3 = 1.3
Sum(PD) = (.1 + .1 + .1) + (.2 + .2) + (.3 + .3) = 1.3