Dual Filtering Syntax

masplin

Active Member
Joined
May 10, 2010
Messages
413
I'm trying to work out which customers buy a 1 year licence and then rebuy it 1 year later (actually within 1 year of the expiry). This requires some sort of nested filtering where I find all the distinct customer in the first set and then look how many are in both sets. I searched around a bit and thought i had the answer but doesn't look right as have more in the "both" set than in the 1st set!

Matchinput is a table of invoices with Match Ref being a customer no

1st Set

Code:
PCC Buyer=CALCULATE( DISTINCTCOUNT(MatchInput[Match Ref]),
                                                MatchInput[PCC Purchase]="yes"
                                               )

2nd Set

Code:
PCC Buyer Next Year=
          CALCULATE( [PCC Buyer],
                             DATESINPERIOD(
                                                      DateTable[Day],
                                                      LASTDATE(
                                                                      DATEADD(DateTable[Day],1,YEAR)
                                                                      ),
                                                          1,
                                                           Year
                                                        )
                             )

These seem to be accurate so I then tried to combine them using some other posts, but obviously hopelessly wrong. If anyone can give me a steer how to filter on Set 1st then apply the Set 2 filter to see who is both that would be really appreciated.

Code:
CALCULATE(                        DISTINCTCOUNT(MatchInput[Match Ref]),
                         FILTER(
                                      DISTINCT(MatchInput[Match Ref]),
                                      [PCC Buyer Next Year]>0
                                      )
                      )
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Rob (at powerpivotpro) and Marco/Alberto (at SqlBI.com) both have articles on the returning customers patterns. They show up easy with a google for "dax returning customers". Though, if that doesn't get you there... I can probably try thinking hard n stuff :)
 
Upvote 0
Somehow haveing a measure that looks into the future is throwing me, I'm apparently a looking back kinda person :)

Your measure doesn't look too far off what I would expect. I would probably use VALUES instead of DISTINCT (but now that I saw that... I'm kinda curious about the diff). And you didn't filter on PCC Purchase. I would expect:

=CALCULATE([PCC Buyer], FILTER(VALUES(MatchInput[Match Ref]), [PCC Buyer Next Year] > 0))
 
Upvote 0

Forum statistics

Threads
1,225,562
Messages
6,185,673
Members
453,314
Latest member
amitojsd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top