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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Calculated Column to find date where the sum of units meets certain value

Delivery_Table: Date a delivery was made and the number of units delivered. Table includes maximum delivery capacity.

Arrival_Units = ( Delivery_Table[Capacity] - Delivery_Table[UnitsDelivered] )

 

Transaction_Table: Date and number of units sold

 

On the Delivery_Table I want to make a calculated column called *Delivery_Table[Arrival Units Expired Date] where the Transaction_Table[Transaction Date] >= Delivery_Table[Delivery Date] && sum of Transaction_Table[Units Sold] >= [Arrival_Units] and returns the Transaction_Table[Transaction_Date] this occurs.

 

Delivery_Table   
     
Delivery DateCapacityDelivered UnitsArrival Units*Arrival Units Expired Date
9/1/202210075259/6/2022

 

Transaction Table 
  
Transaction DateUnits Sold
9/1/20225
9/2/20221
9/3/20224
9/4/20225
9/5/20225
9/6/20225
9/7/20223

 

1 ACCEPTED SOLUTION

Hi , @Anonymous 

You can use this dax , then you can add the "Location ID" condition.

*Arrival Units Expired Date = var _cuurent_arr='Delivery_Table'[Arrival Units]
var _current_deliver_date = 'Delivery_Table'[Delivery Date]
var _cuurent_ID = 'Delivery_Table'[Location ID]
var _t= FILTER('Transaction_Table' , 'Transaction_Table'[Transaction Date] >=_current_deliver_date && 'Transaction_Table'[Location ID] =_cuurent_ID) 
var _t2= ADDCOLUMNS(_t , "sum" , SUMX(FILTER(_t , [Transaction Date] <=EARLIER('Transaction_Table'[Transaction Date])) , [Units Sold]))
var  _t3 =FILTER(_t2 , [sum] >= _cuurent_arr)
return 
MINX(_t3,[Transaction Date])

And i use the new test data, the result is as follows:

vyueyunzhmsft_0-1664502303713.png

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

 

Best Regards,

Aniya Zhang

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

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

@v-yueyunzh-msft I'm unable to figure out how to attach an example file. Your example looks fine just need to add 'Location ID'. Please note that the delivery_table has 3 million rows and the transaction_table has 17 million rows. I did try and run your original code but, was met with the below error. 

 

 <ccon>There's not enough memory to complete this operation. Please try again later when there may be more memory available.</ccon>

Hi , @Anonymous 

You can use this dax , then you can add the "Location ID" condition.

*Arrival Units Expired Date = var _cuurent_arr='Delivery_Table'[Arrival Units]
var _current_deliver_date = 'Delivery_Table'[Delivery Date]
var _cuurent_ID = 'Delivery_Table'[Location ID]
var _t= FILTER('Transaction_Table' , 'Transaction_Table'[Transaction Date] >=_current_deliver_date && 'Transaction_Table'[Location ID] =_cuurent_ID) 
var _t2= ADDCOLUMNS(_t , "sum" , SUMX(FILTER(_t , [Transaction Date] <=EARLIER('Transaction_Table'[Transaction Date])) , [Units Sold]))
var  _t3 =FILTER(_t2 , [sum] >= _cuurent_arr)
return 
MINX(_t3,[Transaction Date])

And i use the new test data, the result is as follows:

vyueyunzhmsft_0-1664502303713.png

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

 

Best Regards,

Aniya Zhang

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

 

Anonymous
Not applicable

@v-yueyunzh-msft Thank you for your reply. I'm confident this will work however, I failed to mention in my previous post there is a 'Location ID' to match to on both tables. Secondly, the next column I'll be making would be 'Delivered Units Expired Date'. I'm not fully grasping the ADDCOLUMNS within the variables so, helping me with both would help me get there. Below is the example tables....

 

dwallsbr_0-1664461994412.png

 

v-yueyunzh-msft
Community Support
Community Support

Hi , @Anonymous 

Here are the steps you can refer to :

(1)This is my test data:

vyueyunzhmsft_0-1664417553862.png

vyueyunzhmsft_1-1664417561205.png

(2)We can create a calculated column in 'Delivery_Table' :

 

*Arrival Units Expired Date = var _cuurent_arr='Delivery_Table'[Arrival Units]
var _current_deliver_date = 'Delivery_Table'[Delivery Date]
var _t= FILTER('Transaction Table' , 'Transaction Table'[Transaction Date] >=_current_deliver_date) 
var _t2= ADDCOLUMNS(_t , "sum" , SUMX(FILTER(_t , [Transaction Date] <=EARLIER('Transaction Table'[Transaction Date])) , [Units Sold]))
var  _t3 =FILTER(_t2 , [sum] >= _cuurent_arr)
return 
MINX(_t3,[Transaction Date])

 

(3)Then we can meet your need , the result is as follows:

vyueyunzhmsft_2-1664417609182.png

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

 

Best Regards,

Aniya Zhang

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.