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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
dregan
Frequent Visitor

Running Total Selecting Latest Datapoint for Each Unique Entity

Hi! I'm trying to come up with a way to have a running total for our inventories that have both a General ID and multiple Unique Load IDs.  The inventory of these unique load IDs change independently, so when I am calculating a running total, I am looking to look at the MOST RECENT data point that is less than or equal to the current datetime for EACH unique Load ID that has the same general load ID.  I made some example data below.  In my actual data source there are also multiple General IDs. 

 

I've tried many different combinations of SUMX and CALCULATE, but none seem to work... 

 

General IDLoad IDQty in LoadTimeRunning total 
12312001:00650
12322001:00650
12331501:00650
12341001:00650
12311502:00450
12321502:00450
12331002:00450
1234502:00450
12311003:00250
12321003:00250
1233503:00250
123403:00250
1231504:00450
12321004:00450
1233504:00450
12352504:00450
1231505:00625
1232755:00625
12333005:00625
12342005:00625

 

6 REPLIES 6
Anonymous
Not applicable

Hi @dregan ,

 

Your running total means get the sum group by time, right?

You can create a measure wich is dynamic,

Measure = CALCULATE(SUM('Table'[Qty in Load]),FILTER(ALLSELECTED('Table'),[General ID]=MAX('Table'[General ID])&&[Time]=MAX('Table'[Time])))

vstephenmsft_0-1646897847141.png

Dynamic results can be obtained by filtering by Load ID.

vstephenmsft_1-1646897874832.png

 

Best Regards,

Stephen Tao

 

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

I don't want to filter by Load ID, unfortunately.  I was the Sum of all the MOST RECENT datapoints for each load ID that are filtered by the General ID (as compared to the datetime value). 

 

i.e. if load 1 has 200 on it on 3/1, the total on 3/1 will inclue that 200.  But if on 3/2 the load drops to 150, he total on 3/2 will only include the 150 and NOT the 200. 

Anonymous
Not applicable

Hi @dregan ,

 

Your Running total in the sample data is not the expected result, is it?

Can you refine your sample data to provide corresponding expected results? The example you provided in the lateset reply includes dates, but there are no dates in the sample data, which confuses me.

 

 

Best Regards,

Stephen Tao

 

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

Yes, it is the expected results.  I only showed Time - but I should have made it a DateTime.  These numbers update multiple times a day, but as time goes on I only want to add the Most Recent datapoint for each Load ID (in the same General ID).

dregan
Frequent Visitor

I think I also need a filter in there for the General ID, as there are a handful of those too, and I want to add all of the Load IDs that are the same General ID.   

amitchandak
Super User
Super User

@dregan , calculate(sumx(values(Table[ Load Time]) , calculate(lastnonblankvalue(Table[Load ID]), Sum(Table[Qty in Load]))), Filter(allselected(Table), [Load Time] <= max(Table[Load Time])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.