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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
timfrikkee
Frequent Visitor

Allocate quantity based on match in another column

Hello community!

 

I have the following problem when trying to calculate a total quantity. 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. See an example below as well.

 

 

Table 1   
Article CodeQuantityContains Tyre
Tyre 1100 
Tyre 2130 
Tyre 3200 
Wheel 150Tyre 1
Wheel 230Tyre 3
Wheel 340Tyre 2
Wheel 440Tyre 1
Wheel 560Tyre 2

 

 

Desired Result   
Article CodeQuantityContains TyreTotal Quantity
Tyre 1100 190
Tyre 2130 230
Tyre 3200 230
Wheel 150Tyre 150
Wheel 230Tyre 330
Wheel 340Tyre 240
Wheel 440Tyre 140
Wheel 560Tyre 260

 

I hope my request is clear and thanks in advance for any help! 

 

Greetings,

 

Tim

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@timfrikkee , Create a new column

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

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@timfrikkee , Create a new column

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

Hello Amitchandak,

 

I use above solution in a calculation per month. However, the combinations of tyre and wheel can differ per month (sometimes we only have one combination sometimes two) and the formula seems to only sum those months where all combinations are present. The months in which only one tyre and wheel combination is present are not summed.

 

Do you a solution for this issue?

 

Thanks!

Wauw thank you so much that worked perfectly and a very quick response! One more question though is that I need this to be also filtered per date. How can I insert that into this formula?

 

Thanks a lot!

Hello community, I have found that the solution to my question above was a calculate and allexcept combination. 

 

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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