cancel
Showing results for
Did you mean:
Frequent Visitor

## Issue with allocating quantity based on match in another column

Hello Community!

In a previous post I had the following problem:

I have a table containing a list of article codes that represent tyres or wheelsets. All have a forecasted quantity. The wheelsets consist of both a tyre and a tube. Thus, to calculate the total forecasted quantity of a tyre I need to take into account the corresponding wheelset quantities as well. Important to note is that there are tyres that exists in multiple wheelset combinations.

The aim is to sum the forecasted tyre quantity plus the wheelset quantity that contains the tyre to come to a total forecasted quantity per article code.

This issue was quickly resolved with the following formula:

new column =
var _t1 = [Article Code]
return
[Quantity] + sumx(filter(Table, Table[Contains Tyre] = _t1),[Quantity])

However, it does not work when a wheel contains a tyre for which there is no quantity as a single item. In the example below I have illustrated the issue with "Wheel 6" and "Tyre 4". Where there is no forecasted quantity for Tyre 4 but there is for Wheel 6 and since this wheel contains Tyre 4 the quantity for the wheel should be allocated to the Tyre as well.

 Table 1 Article Code Quantity Contains Tyre Tyre 1 100 Tyre 2 130 Tyre 3 200 Wheel 1 50 Tyre 1 Wheel 2 30 Tyre 3 Wheel 3 40 Tyre 2 Wheel 4 40 Tyre 1 Wheel 5 60 Tyre 2 Wheel 6 20 Tyre 4

 Desired Result Article Code Quantity Contains Tyre Total Quantity Tyre 1 100 190 Tyre 2 130 230 Tyre 3 200 230 Tyre 4 0 20 Wheel 1 50 Tyre 1 50 Wheel 2 30 Tyre 3 30 Wheel 3 40 Tyre 2 40 Wheel 4 40 Tyre 1 40 Wheel 5 60 Tyre 2 60 Wheel 6 20 Tyre 4 20

I hope you can help me with perfecting this formula for it greatly reduced workload for me! I hope the examples are clear and any help is much much appreciated.

Best regards,

Tim

1 ACCEPTED SOLUTION
Super User IV

@timfrikkee , Try a new measure for total quantity and check

sum(Table[Quantity]) + calculate(sum(Table[Quantity]), filter(allselected(Table), Table[Contains Tyre] = max(Table[Article Code])))

or

sum(Table[Quantity]) + calculate(sum(Table[Quantity]), filter(allselected(Table), Table[Contains Tyre] = max(Table[Article Code])))+0

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

2 REPLIES 2
Community Champion

Hi, @timfrikkee

I am not sure if I understood correctly your question, but I suggest creating a new table.

Please check the below picture and the sample pbix file's link down below.

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Super User IV

@timfrikkee , Try a new measure for total quantity and check

sum(Table[Quantity]) + calculate(sum(Table[Quantity]), filter(allselected(Table), Table[Contains Tyre] = max(Table[Article Code])))

or

sum(Table[Quantity]) + calculate(sum(Table[Quantity]), filter(allselected(Table), Table[Contains Tyre] = max(Table[Article Code])))+0

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Announcements

#### 2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

#### Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors