I currently trying to Implement a Calculated Member (SSRS or SSAS ) which would Show me the Average Values per Customer, I need to divide the Sum of Values from all Projects, and divide it by the amount of Projects that don't have 0 as a Value.
A similar table of Values like the one I am using is shown below.
> Customer | Project | Value |
> Customer1 | Project1 | 124.24... |
> Customer1 | Project2 | 0.00 |
> Customer1 | Project3 | 242.221... |
> Customer1 | Project3 | 72.221... |
now what i tried to do in my Calculated Member is the following (i tried this in both SSRS and SSAS)
Sum([Measures].[Value]) /Count(Filter([Order].[Project], [Measures].[Value] > 0))
My hope was to filter out the Amount of Projects that have a Value of Zero, and divide the sum of Values only by the Amount of Projects that have a Value of <> 0.
the Problem is, when i get to the browser so I try my Calculated Member out the Count Value of Projects (relative to the ex. above) is 1 instead of 3, and the Average value I get is :
(124.24 + 0 + 242.221 + 72.221) / 1
as opposed to
(124.24 + 0 + 242.221 + 72.221) / 3
(not devide by 4 because 1 project has the value of 0, and that's the one I want to exclude from the Count that I make).
My question has been answered on the MSDN Forums by Duane Dicks, which I'm gonna post below.
" think why you are only getting 1 instead of 3 is because your filter is only looking at the all member and it should be looking at it's children.
Something like this should do it:
Sum([Measures].[Value]) /Count(Filter([Order].[Project].level(0).Children, [Measures].[Value] > 0))
" MSDN: How to find the Average in a Calculated Member with filtered Values?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.