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

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.

Reply
Anonymous
Not applicable

Using DAX to Calculate Number of Customers Who Have Met Threshold

I have a model that includes a fact table that shows individual order data and filter tables for our Item Master and Customer Master, connected with a one-to-many relationship to the fact table. The model also includes a table that holds designated thresholds for a couple of product types and customer segments that is not connected to any of the other tables.

 

I have a DAX query that calculates the number of customers who have sold a specific number of products and it seems to calculate correctly. However, it is slower than I would like, typically taking around at least 8-12 seconds for the query alone and sometimes throwing a memory error depending on selected filters.

 

This query starts by totaling up the number of customers without blank values:

 

Total Customers = 
    CALCULATE(
        SUM( 'Customer Master'[Customers] ),
        FILTER(
            'Customer Master',
            NOT( ISBLANK( [Total Pieces] ) )
        )
   )

 

 

I then calculate the product thresholds using TREATAS to connect to the master tables:

 

Total Threshold = 
    CALCULATE(
        SUM( 'Thresholds'[Threshold] ),
        TREATAS( VALUES( 'Customer Master'[Segment] ), 'Thresholds'[Segment] ),
        TREATAS( VALUES( 'Item Master'[Product Family]), 'Thresholds'[Product] )
    )

 

 

Finally, the query in question calculates how many customers have reached or exceeded the thresholds:

 

Customers Meeting Threshold = 
        CALCULATE(
            [Total Customers],
            FILTER( 
                'Customer Master',
                [Total Units] >= [Total Threshold]
            )
        )

 

 

Does anybody have a recommendation for helping the efficiency of this query?

1 REPLY 1
PaulDBrown
Community Champion
Community Champion

@Anonymous 

Can you please include a sample/ dummy data of the tables involved to recreate the model and measures?

I take it you are trying to filter by the threshold table, correct?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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