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
sabd80
Helper II
Helper II

Slow Summarize measure

Hi,

I have below measure running very slow specialy for monthly and yearly period:

 

Constrained DIF MISS =
VAR NewTable=
FILTER(ADDCOLUMNS(
       SUMMARIZE('Sales Order Details', 'Sales Order Details'[Order Number]),
       "Qty",[Qty Ordered Running Total OrderNo]- [Qty Shipped Running Total OrderNo]
),[Constrained DIF Flag]="Yes"
)
VAR MaxOrder = maxx(NewTable, [Order Number])
return
sumx(FILTER(NewTable,'Sales Order Details'[Order Number]= MaxOrder), [Qty])
 
The orther measures used in above are:
 
Constrained DIF Flag =
IF (ISBLANK([Quantity Shipped]), BLANK(),
       IF([Qty Shipped Running Total OrderNo] <= SUM('Day 0 Business Plan'[Day 0 Business Plan - Cases]),
        "Yes",
        "No"
       )
)
 
Qty Ordered Running Total OrderNo =
CALCULATE([Quantity Ordered],
       FILTER(ALLSELECTED('Sales Order Details'), 'Sales Order Details'[Order Number]<= max('Sales Order Details'[Order Number]))
       
)
 
Qty Shipped Running Total OrderNo =
CALCULATE([Quantity Shipped],
       FILTER(ALLSELECTED('Sales Order Details'), 'Sales Order Details'[Order Number]<= max('Sales Order Details'[Order Number]))
       
)
I cann't provide the pbxi file.
Can it be optimized?
 
Thanks.
4 REPLIES 4
sabd80
Helper II
Helper II

 

Thanks @johnt75 , your dax return the correct order number, but the value of below

[Qty Ordered Running Total OrderNo] - [Qty Shipped Running Total OrderNo]
 

returns the value at the order number level, not the running total as in below screenshot.

I need to display this measure in a card visual, your measure will show 0, mine will show 388,635.

 

2022-12-23_9-25-26.png

Try changing it to

FILTER ( NewTable, 'Sales Order Details'[Order Number] <= MaxOrder ),

Just a bit of correction.

that would show the cummulative value, that is not what I what want, I need the value of the difference up to the maximum order number.

johnt75
Super User
Super User

Try

Constrained DIF MISS =
VAR NewTable =
    FILTER (
        VALUES ( 'Sales Order Details'[Order Number] ),
        [Constrained DIF Flag] = "Yes"
    )
VAR MaxOrder =
    MAXX ( NewTable, [Order Number] )
RETURN
    SUMX (
        FILTER ( NewTable, 'Sales Order Details'[Order Number] = MaxOrder ),
        [Qty Ordered Running Total OrderNo] - [Qty Shipped Running Total OrderNo]
    )

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.