SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Count Comparison Month over Month - doesn't work when filtered


Count Comparison Month over Month - doesn't work when filtered

Author
Message
Chris Becker
Chris Becker
Old Hand
Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)

Group: General Forum Members
Points: 322 Visits: 268
My first dive into MDX. I have a calculation which works when 2 entire months are compared. When I filter the Transaction Date to compare e.g. September Days 1 to 10 to October Days 1 to 10, this calc does not work. It still shows a difference in count of 30 days in September (entire month) vs October, so counts are ALL negative. How do I resolve? Tia!!

Case
// Test for current coordinate being on (All) member.
When [Transaction Date].[Date Hierarchy].CurrentMember.Level Is
[Transaction Date].[Date Hierarchy].[(All)]

Then "NA"

// Test to avoid division by zero.
When IsEmpty
(
(
ParallelPeriod
(
[Transaction Date].[Date Hierarchy].[Month],
1,
[Transaction Date].[Date Hierarchy].CurrentMember
),
[Measures].[Checks Count]
)
)
Then Null

Else (
( [Transaction Date].[Date Hierarchy].CurrentMember,
[Measures].[Checks Count])
-
(
ParallelPeriod
(
[Transaction Date].[Date Hierarchy].[Month],
1,
[Transaction Date].[Date Hierarchy].CurrentMember
),
[Measures].[Checks Count]
)
)

End



Chris Becker
Chris Becker
Old Hand
Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)

Group: General Forum Members
Points: 322 Visits: 268
Would be nice to have something more re-usable. I found this code with a google search, however is limited when drilling through Transaction Date dim, will not work when Year or Quarter selected.

Do I need to create another calculated measure for these?? Seems to clutter up measures group fast and is not flexible

Thanks in advance for any help,
Chris



Mackers
Mackers
SSC Veteran
SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)SSC Veteran (223 reputation)

Group: General Forum Members
Points: 223 Visits: 499
Is this not working for September Days 1 to 10 or are you looking for an aggregated view of September Days 1 to 10?

The query looks like it should work fine for each individual days...

Mack
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search