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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
cy-user
Frequent Visitor

Power BI Dax issue with running total measure that repeats total if date is repeated

I have been searching for a solution to this seemingly simple request but to no avail.

I am trying to get a running total per item that never resets.  My measure fails to give the specific total when there is more than one order for an item on the same day, it just repeats the total for the item for the day.

In my example, I am using a running total measure and a Visual Calculation.

 

I am only showing two items: 10100112 and 10100565.

 

I would love help with EITHER calcualtion. A Visual Calculation would be best because it will be faster, especially once I add all items to the report.  The benefits of using the RUNNINGSUM function if I could figure that out is that it seems to recalculate the running totals if you change the sort order of the date.

The 'mRTQtyremain' calculation is:

mRTQtyremain =
VAR varDate = SELECTEDVALUE('DateTable'[Date])
VAR varItem = SELECTEDVALUE(Sales_Order_Line_Excel[No])
RETURN
    CALCULATE(
        [mQtyRemain],
        ALLSELECTED(Sales_Order_Line_Excel),
        'DateTable'[Date] <= varDate,
        Sales_Order_Line_Excel[No] = varItem
    )

 

The Visual Calculation is: (Not using RUNNINGSUM, but would like to)

Visual Calculation = SUMX(WINDOW(1, ABS, 0, REL, ALL([Date],[Item No],[mQtyRemain]), ORDERBY([Date]), PARTITIONBY([Item No])),[mQtyRemain])
 
This is where they both go wrong for what I need:
cyuser_0-1738070782528.png


Here is some sample data you can put into a blank query in the editor:

Location_CodeDateItem NoOrder_NoQty_Remain
MAIN3/14/202510100565S-ORD1834910
MAIN2/14/202510100565S-ORD1834815
MAIN1/15/202510100565S-ORD183591
MAIN1/14/202510100565S-ORD1834715
MAIN1/13/202510100112S-ORD1833820
MAIN1/13/202510100112S-ORD183435
MAIN1/13/202510100565S-ORD183435
MAIN1/9/202510100112S-ORD1831820
MAIN1/8/202510100565S-ORD12771
MAIN1/8/202510100565S-ORD183091
MAIN1/3/202510100112S-ORD1827235
MAIN12/19/202410100565S-ORD182145
MAIN11/18/202410100112S-ORD1802715
MAIN11/14/202410100112S-ORD180053
MAIN11/11/202410100112S-ORD173064
MAIN11/4/202410100565S-ORD174142
MAIN11/1/202410100565S-ORD174651
MAIN10/23/202410100565S-ORD173007
MAIN10/23/202410100565S-ORD173017
MAIN10/23/202410100565S-ORD173034
MAIN10/21/202410100565S-ORD178692
MAIN9/30/202410100565S-ORD12631
MAIN9/30/202410100565S-ORD177544
MAIN9/30/202410100565S-ORD177581
MAIN9/19/202410100565S-ORD176941
MAIN9/17/202410100565S-ORD176751
MAIN9/13/202410100565S-ORD175635
MAIN9/13/202410100565S-ORD176651
MAIN9/11/202410100112S-ORD1762935
MAIN9/11/202410100565S-ORD176342
MAIN9/3/202410100565S-ORD175371
MAIN8/20/202410100112S-ORD173592
MAIN8/15/202410100112S-ORD173052
MAIN8/14/202410100112S-ORD172811
MAIN8/9/202410100112S-ORD172271
MAIN8/9/202410100565S-ORD172302
MAIN7/11/202410100112S-ORD1691050



Thank you in advance for your time.

1 ACCEPTED SOLUTION
cpride
Regular Visitor

This issue was resolved with the help of @jeroenterheerdt .

This WINDOW function worked for my requirements, which I used as a Visual Calcualtion:

 

Visual Calculation = SUMX(WINDOW(1, ABS, 0, REL, ALLSELECTED([Date],[Item No],[Order_No]), ORDERBY([Date]), PARTITIONBY([Item No])),[Qty_Remain])

View solution in original post

4 REPLIES 4
cpride
Regular Visitor

This issue was resolved with the help of @jeroenterheerdt .

This WINDOW function worked for my requirements, which I used as a Visual Calcualtion:

 

Visual Calculation = SUMX(WINDOW(1, ABS, 0, REL, ALLSELECTED([Date],[Item No],[Order_No]), ORDERBY([Date]), PARTITIONBY([Item No])),[Qty_Remain])

glad we got it working and thanks for your feedback!

Anonymous
Not applicable

Hi @cy-user 


The calculation issue you encountered might be due to a blank 'Item No'. If possible, please fill in the blank 'Item No'.

 

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I have attached the data and also shared a link to the sample report.  There are only 37 rows in this example and no blanks.

 

Can you please see if you can tell what I am doing wrong?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors