I have a query that does a distinct count of accounts based on CB score. The problem I have is that an account can switch credit scores pretty often. So I would like to take the max credit score for a particular account. Here is what I have that is returning higher than I want because of the switching of CB scores.
So for example account 1234 initially has a cb score of 500, then later has a cb score of 550. The account 1234 is now in both cb score ranges, but I only want to count them once.
WITH
MEMBER mem1 AS
Count
(
NonEmpty
(
[AccountID].[Account ID].[Account ID].MEMBERS
,measures.[Transaction Amount]
)
)
SELECT
NON EMPTY
{mem1} ON 0
,[CB Score].[RANGE].[RANGE] ON 1
FROM [CUBE]
WHERE [PROMO].[PROMO].&24
Try this:
Basically the logic is to count the account if they had a transaction in that slice and if no greater CB Score range has a transaction.