Sunday, February 19, 2012

Filtering without a tuple-set ?

a normal Filter with a tuple-set:

Filter(
[Brand].members,
(([Measures].[Sale],
[Posting Period].[Year].&[2005]) > 0)
)

The brands where we sold something in the year 2005. This works fine but....

a Filter within a range of days ? :

Filter(
[Brand].members,
(([Measures].[Sale],
ClosingPeriod([Posting Period].[Day]).lag(365):ClosingPeriod([Posting Period].[Day]))) > 0)

The brands where we sold something in a range between currentday -365 days and currentday.
This won't work with the filter-function ! Is there an other way to do this ?

Kind regards

If your Sales measure does not contain negatives you could simply aggregate the measure for the range of dates.

Filter(
[Brand].members,
Aggregate(ClosingPeriod([Posting Period].[Day]).lag(365)
:ClosingPeriod([Posting Period].[Day]
,
[Measures].[Sale] ) > 0)

If your measure might contain negative figures and there is a chance that a date range could sum to 0 even though there are sales for the specified period, you might be better off getting a count of the non empty cells.

Filter(
[Brand].members,
NonEmpty(ClosingPeriod([Posting Period].[Day]).lag(365)
:ClosingPeriod([Posting Period].[Day]
,
[Measures].[Sale] ).Count > 0)

No comments:

Post a Comment