Machinist26
New Member
- Joined
- Aug 19, 2015
- Messages
- 2
I'm not sure why I can't make this work, but I'm having a terrible time trying to filter based on a calculated field. The intent:
To calculate the average unit price from a sales data set. I have this part. Then to report the revenue from sales where the unit price was less than the previously calculated average. Basically a glorified SUMIF.
Sample data set:
Unit Price Volume Sales
0.221517426 90.48281858 20.04352108
0.150546562 74.83994718 11.26689675
0.125449802 65.50048886 8.217023344
0.652954905 0.614463156 0.401216732
0.895887196 21.10741268 18.90986076
0.745563837 13.42812059 10.01152111
Calculated field "average" is defined as:
SUM(Table1[Sales])/SUM(Table1[Volume])
And it works. No problem.
Now I'm trying to use FILTER() to filter out ever line from the source data table whose unit price is less than "Average":
SUMX(filter(Table1,Table1[Unit Price]<[Average]),Table1[Sales])
And the numbers I get don't make sense. If I replace the measure with a constant, the resulting value is correct:
SUMX(filter(Table1,Table1[Unit Price]<0.39279385),Table1[Sales])
Where am I going wrong?
To calculate the average unit price from a sales data set. I have this part. Then to report the revenue from sales where the unit price was less than the previously calculated average. Basically a glorified SUMIF.
Sample data set:
Unit Price Volume Sales
0.221517426 90.48281858 20.04352108
0.150546562 74.83994718 11.26689675
0.125449802 65.50048886 8.217023344
0.652954905 0.614463156 0.401216732
0.895887196 21.10741268 18.90986076
0.745563837 13.42812059 10.01152111
Calculated field "average" is defined as:
SUM(Table1[Sales])/SUM(Table1[Volume])
And it works. No problem.
Now I'm trying to use FILTER() to filter out ever line from the source data table whose unit price is less than "Average":
SUMX(filter(Table1,Table1[Unit Price]<[Average]),Table1[Sales])
And the numbers I get don't make sense. If I replace the measure with a constant, the resulting value is correct:
SUMX(filter(Table1,Table1[Unit Price]<0.39279385),Table1[Sales])
Where am I going wrong?