So I have the following pivot table report through my data model. I want my measure 'Branches Per Cluster' to consider the current column of month or year.
I have the following tables aside from a generated calendar table, these two below are related by 'CODE'.
A dim table named 'Branch Profiles'
| CODE | AREA | CLUSTER | DATE OPENED |
|---|---|---|---|
| AAA | Area 1 | Cluster 1 | 01/05/1990 |
| AAB | Area 1 | Cluster 1 | 05/03/2022 |
| ABA | Area 2 | Cluster 1 | 01/03/2005 |
| BAA | Area 3 | Cluster 2 | 01/03/2024 |
A fact table named 'BasicData'
| CODE | Volume | Value | Date |
|---|---|---|---|
| AAA | 1000 | 10000 | 06/01/1990 |
| AAB | 2000 | 20000 | 06/01/2020 |
| ABA | 3000 | 30000 | 06/01/2005 |
| BAA | 4000 | 40000 | 06/01/2008 |
This is what I currently have for my Branches Per Cluster measure which might be obvious for experienced users that is syntactically wrong though I believe it shows what I was trying to do as
I'm not quite sure how to reference the column as a filter. Basically, I just want to count the Branches ("CODE") for the specific area that have a date opened before the month specified by the column filters.
=CALCULATE(
DISTINCTCOUNT('Branch Profiles'[CODE]),
ALLEXCEPT('Branch Profiles',
'Branch Profiles'[AREA],
'Branch Profiles'[CODE]
),
YEAR('Branch Profiles'[DATE STARTED]) <= 'Calendar'[Year],
MONTH('Branch Profiles'[DATE STARTED]) <= 'Calendar'[Month Number]
)
