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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

New column based on fixed amount

Hi

 

I've got two tables named Procurement and Stock.

Procurement contains columns "Confirmed delivery date" and "Procurement Amount".

Stock contains columns "Available stock", which is a current fixed amount. The tables are related based on "SKU" which is a part of both tables.

 

So right now i've got a matrix table looking like this:

 

Product                    Procurement Amount                    Available Stock

SKU1                                   718                                            -377

     16. april 2021                 268                                            -377

     14. may 2021                 151                                            -377

     24. june 2021                 149                                            -377

     4. july 2021                     150                                           -377

 

I want to create a column stating the available stock after the procurement amount and thereby being capable of possibly creating a date table where "New available stock" > 0 in order to show the next date that entails available stock. So essentially something like:

 

Product                    Procurement Amount                    Available Stock                    New Available Stock

SKU1                                   718                                            -377

     16. april 2021                 268                                            -377                                      -109     

     14. may 2021                 151                                            -377                                        42(-109+151)            

     24. june 2021                 149                                            -377                                        191(42+149)     

     4. july 2021                     150                                           -377                                        341(191+150)

 

And afterwards create a table visual stating next available stock date = 14. may 2021.

 

Hope you can help. 

 

 

5 REPLIES 5
ERD
Community Champion
Community Champion

Hello @Anonymous ,

Well, from the examples you've provided here is what can be concluded:

  • you have a constant here which is called Available Stock and = -377 
  • your new column calculation:
    • first element = constant + current Procurement Amount (-377 + 268)
    • all other elements = current Procurement Amount + previous row calculation result

Is this what you want to achive?

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Anonymous
Not applicable

Exactly @ERD ! 🙂

ERD
Community Champion
Community Champion

Another approach is just sum all the previous Procurement Amount values from the start until the current one. In this case you can use DAX:

 

Result = 
var firstDateValue = MIN(Table[Date])
var currentDate = Table[Date]
var constant = -377
var valueOnFirstDate = CALCULATE(MAX(Table[ProcurementAmount]) + constant, FILTER(Table, Table[Date] = firstDateValue))
var sumValue = CALCULATE(SUM(Table[ProcurementAmount]), FILTER(Table, Table[Date] <= currentDate))
var result = IF(Table[Date] = firstDateValue, valueOnFirstDate, constant + sumValue)
return
result

 

 

Did I answer your question? Mark my post as a solution!

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

ERD
Community Champion
Community Champion

 If you want to have a Calculated DAX column that uses the previous row's calculated value as an input, thenDAX won't help you as DAX cannot do recursion. You can read the explanation here: Refer to previous row of same column.

Power Query instead can be used to achieve the result.

Here is the code that might help (it might be not the most elegant one, but it works):

 

#"Added Index" = Table.AddIndexColumn(#"Previous step", "Index", 1, 1, Int64.Type),
#"Added CalcStep1" = Table.AddColumn(#"Added Index", "CalcStep1", each if [Index] = 1 then -377 + [ProcurementAmount] else [ProcurementAmount]),
#"Added Column" = Table.AddColumn(#"Added CalcStep1", "Result", each  List.Accumulate(List.Range(#"Added CalcStep1"[CalcStep1],0,[Index]),0,(state,current)=> state+current)),
#"Removed Columns" = Table.RemoveColumns(#"Added Column",{"Index", "CalcStep1"})

 

The idea here was to create an Index column, get the list of Procurement Amount values with  the first element changed by constant and then calculate the result. Transitional columns may be deleted afterwards.

In a table visual any filter can be used further (like Result >0, etc.).

 

 

Did I answer your question? Mark my post as a solution!

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

selimovd
Super User
Super User

Hey @Anonymous ,

 

when you have a column with the procurement amount and no other column, then it's hard to calculate the new amount. Do you have another column that shows the consumption of the product in the time frame?

 

I also don't know what I should do with the column "Available Stock". You write -377 every row but I don't see that you really use that column.

 

 Could you explain your columns a little better?

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.