Hello, attached a XLSX file with 4 tabs , for simplying reason I have put them in a single file.
the problem is food distribution for poor people
member list ( tab)
this weekly list the people that are entitled for the products ( listed in the matrix )
the KEY code is related with the matrix
products (tab ) ( the list of possible products to distribute )
Target (tab ) the list of available product for a particular week
matrix (tab ) the number of products for each KEY and product for that week
how to calculate (tab ) you will see that according the matrix I will need more product ( example Milk 1228 ) than there is available target 1050
therefore I have to adjust the matrix to get close to the target
for the moment this is done manually ( see tab )
any help is greatly appreciated
Roger RECURSIVE calculation POWER BI or EXCEL.xlsx (69.1 KB)
thanks for looking at this problem,
the order I choose is the “total per key” (column L) starting with the KEY *N and the highest number for that key
( they have no childern and the priority is the family with childern *Y the 4N and 5 N have only 4 as total so I skip them and start with the high number ending with *Y until I get below the target.
hope this makes sense
kind regards
Roger
Hi @Roger - I have tried to come up with attached solution. Do check if it is helpful. I have created a Index Column based on the keys from Matrix.
For information, I can’t skip values for “4N and 5N” considering solution needs to be dynamic.
Primarily entire calculations id done on Matrix table. From Members, I have only taken Members Count for each key and Qty available from Target. Recurrsive.pbix (54.2 KB)
Hello again, thanks for the pbix and the time you spent in solving this problem. It’s more complicated,
each member on the members list must receive at least 1 product that is on the matrix list. in your table the value for 3Y is empty
I have attached the xlsx file with some more info check the tab MATRIX ( explains the path to folow ) check the pivot for milk and pivot for rice ( for the expected result ) and check the tab desired result ( the individual list of products I finally need )
found a solution for the recursive calculation , first create a function to calculate the adjusted quantity, then wrapped it in a query to run for each prod -ID ( see adjusted quantities for each member )