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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

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 CodeQuantityContains Tyre
Tyre 1100 
Tyre 2130 
Tyre 3200 
Wheel 150Tyre 1
Wheel 230Tyre 3
Wheel 340Tyre 2
Wheel 440Tyre 1
Wheel 560

Tyre 2

Wheel 6 20

Tyre 4

 

 

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

 

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
amitchandak
Super User
Super User

@Anonymous , 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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

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.

 

Picture4.png

 

 

https://www.dropbox.com/s/rmvida7yz92x0zg/timfrikkee.pbix?dl=0 

 

 

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.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


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


Click here to visit my LinkedIn page

amitchandak
Super User
Super User

@Anonymous , 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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.