Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Bokazoit
Continued Contributor
Continued Contributor

Is there a better way to handle this date control in my measure?

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?

2 REPLIES 2
johnt75
Super User
Super User

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.

Bokazoit
Continued Contributor
Continued Contributor

Thank You so much!!!! You made my day better 😉

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.