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.
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?
@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?
Proud to be a Super User!
Paul on Linkedin.
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 |
---|---|
110 | |
96 | |
77 | |
63 | |
55 |
User | Count |
---|---|
143 | |
109 | |
89 | |
84 | |
66 |