Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Before I created my memberbase on historical subscriptions per member. That was a small table consisting of 250.000 rows and this measure to show historical development over time worked well:
Memberships=
Var MaxDate = MAX ( DimDate[Date] )
RETURN
CALCULATE(
CALCULATE (
COUNT ( FactDonor[#Donornummer] ),
FILTER (
FactDonor,
(
FactDonor[CreateDate] <= MaxDate
&& FactDonor[EndDate] > MaxDate
)
),
ALL ( DimDate )
),
CROSSFILTER ( FactDonor[CreateDate], DimDate[DateKey], NONE )
)
Now I had to add more change to members, so that I for each row look at membership date as well as changes to other parts such as adress and member-specific things. That means that I have to create lines with change date within the membership dates. It only for added a little over 100.000 rows and my measure now looks like this:
Membership =
Var MaxDate = MAX ( DimDate[Date] )
RETURN
CALCULATE(
CALCULATE (
DISTINCTCOUNT ( FactDonor[#Donornummer] ),
FILTER (
FactDonor,
(
FactDonor[CreateDate] <= MaxDate
&& FactDonor[EndDate] > MaxDate
)
),
FILTER (
FactDonor,
(
MaxDate >= FactDonor[ChangeStartingDate]
&& MaxDate <= FactDonor[ChangeEndingDate]
)
),
ALL ( DimDate )
),
CROSSFILTER ( FactDonor[CreateDate], DimDate[DateKey], NONE )
)
My main issue is that the measure is way slower, when creating a chart with memberships per month since january 2021. So is the new measure written correctly or would You handle the change part differently?
There's a couple of things you could clean up. As you're already using ALL(DimDate) there is no need to set the cross filter direction to none as no filters are being applied.
You're also filtering the entire fact table, its better to just filter the columns you need.
You can try
Membership =
VAR MaxDate =
MAX ( DimDate[Date] )
RETURN
CALCULATE (
DISTINCTCOUNT ( FactDonor[#Donornummer] ),
FactDonor[CreateDate] <= MaxDate
&& FactDonor[EndDate] > MaxDate
&& MaxDate >= FactDonor[ChangeStartingDate]
&& MaxDate <= FactDonor[ChangeEndingDate],
ALL ( DimDate )
)
It may also be worth comparing the performance of this measure with a version where the filters are applied individually, so rather than using && to combine them you simply use commas to separate them into different clauses.
Thank You so much!!!! You made my day better 😉
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
46 | |
26 | |
21 | |
12 | |
8 |
User | Count |
---|---|
74 | |
52 | |
45 | |
15 | |
12 |