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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
sgeheeb
Resolver I
Resolver I

Performance issue when calculating quantity between two dates

Hi,

 

I have the following DAX-Code for a measures which calculates the total quantity between two dates:

1: EndDate is the last date in the slicer selection

2: FirstDate is the first date on which a delivery was made

 

The measures is supposed to be used in a list / matrix to display the quantity of items delivered to a customer. I cannot use the MIN() of the slicer selection, since this is used to filter for sales and deliveries may have been made before that.

This is my code:

 

Quantity Deliverd = 

//Date of first item delivery to customer
VAR firstItemDelivery = CALCULATE(
    MIN(Shipments[Posting Date]),
        ALL('Posting Date'))
//Last date in selection
VAR endDate = MAX('Posting Date'[Date])

//Calculate change of stock at customer
VAR qtyChangeinPeriod =
    CALCULATE (
        SUM (Shipments[Quantity]),
            ALL('Posting Date'[Date]),
            'Posting Date'[Date] >= firstItemDelivery,
            'Posting Date'[Date] <= endDate
        )
RETURN qtyChangeinPeriod

 

When I use this in a list with Items and Customers, the computation runs out of memory.

Does anyone have an idea why this is happening? In my optionion this is not an extraordinarily expansive operation.

 

Cheers

1 REPLY 1
lbendlin
Super User
Super User

Fire up your copy of DAX Studio and examine the query plan for that measure. Check for cross joins. Refactor.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.