Quantcast
Channel: SQL Server Analysis Services Forum
Viewing all articles
Browse latest Browse all 2472

Count Active Customers using DAX

$
0
0

Hello,

Could you please advise me how to count customers with active subscription? The goal is creating an expression that can be pivoted by any dimension in the model.

This is simplified data model:

Transaction Table

Subscription ID

Organization ID

Transaction Date

Is Active

1

1

2012/01/01

0

1

1

2012/01/15

1

1

1

2012/03/27

1

1

1

2012/04/27

0

2

2

2012/02/16

1

2

2

2013/02/15

0

3

1

2012/03/01

0

3

1

2012/03/02

1

3

1

2012/08/31

0

4

3

2012/06/12

1

Customer Table

Organization ID

Customer ID

1

A

2

B

3

A

Let’s say report is as of March close (2012/03/31). The formula should pick up last valid entry per each subscription before 2012/03/31 EOD (green or orange highlighted rows) and count distinct Customers IDs related to record with Is Active = 1 (Customer IDs related to green highlighted rows). Expected value for this example is 1 (customer A has two active subscriptions).

I’ve tried multiple versions of following:

-          Calculated Column in Customer Table [Is Active]: = maxx(related(‘Transaction Table’[Subscription ID]’),LastNonBlank(‘Transaction Table’[Is Active], ‘Transaction Table’[Is Active])

-          Measure in Customer Table: [Active Customer Count]:=calculate(DistinctCount(‘Customer Table’[Customer ID], ‘Customer Table’[Is Active] = 1)

My solution doesn’t work. The [Is Active] complains it can’t determine (‘Transaction Table’[Subscription ID]’ in current context and I don’t see any other way how it could be work-arounded.

Please let me know if you have any recommendations.

Many thanks for any help!

Daniel


Viewing all articles
Browse latest Browse all 2472

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>