Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make Avg() on filtered data

Status
Not open for further replies.

gbim

Programmer
Aug 2, 2005
2
US
Hi,

I need help in this problem.
For example I have the query below in Web Components
Calendar Price Avg
200505 50
200506 23
200507 45
200508 33
200509 23
200510 56
200511 32
200512 12 30,75 <<--- Calculated Member

Avg = (12 + 32 + 56 + 23) / 4 = 30,75

Calculated Member MDX
if([Calendar].CurrentMember.Level.Ordinal=0,null,Avg([Calendar].Lag(3):[Calendar], [Measures].[Price]))

Everything works fine, but when I filter some data in Web Componentes the calculation needs to be made in filtered data...

Calendar Price Avg
200505 50
200506 23
200507 45
200508 33
200512 12 30,75 <<--- Wrong value

The value 30,75 is wrong.
The correct value should be 28,25
Avg = (12 + 33 + 45 + 23) / 4 = 28,25

Anyone knows if it's possible to make the average with the filtered data ?

Thanks !

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top