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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ThiagoMi88
Regular Visitor

Division with filtered field

Hello guys,

I have a table where one column has the products manufactured, in another column the raw materials, 
but there is also the record of the manufactured product, as you can see below. In the third column
I have the amount of raw material used and the manufactured quantity of the product. I need the quantity of raw material per unit of the product manufactured, so I need to divide the
quantity of each raw material by the quantity of the product, which is in the same column.

ProductComponentAmount
Pro11RawMaterial110
Pro11RawMaterial212
Pro11RawMaterial36
Pro11RawMaterial44
Pro11RawMaterial52
Pro11Pro1120
In this example, I would have to divide the quantity of the rawmaterial1 by the quantity of the product (10/20 = 0.5).
That is, we used 0.5 of the rawmaterial1 for each 1 of Pro11
 

 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @ThiagoMi88 

Create two measures

amount_product =
CALCULATE (
    SUM ( Table1[Amount] ),
    FILTER (
        ALLEXCEPT ( Table1, Table1[Production Order], Table1[Product] ),
        LEFT ( Table1[Raw Material], 3 ) = "Pro"
    )
)

 

Expected result = MAX(Table1[Amount])/[amount_product]

11.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

12 REPLIES 12
v-juanli-msft
Community Support
Community Support

Hi @ThiagoMi88 

Create two measures

amount_product =
CALCULATE (
    SUM ( Table1[Amount] ),
    FILTER (
        ALLEXCEPT ( Table1, Table1[Production Order], Table1[Product] ),
        LEFT ( Table1[Raw Material], 3 ) = "Pro"
    )
)

 

Expected result = MAX(Table1[Amount])/[amount_product]

11.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

=[Amount]/CALCULATE(SUM(Data[Amount]),FILTER(Data,Data[Component]=EARLIER(Data[Product])))

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

First of all,

Thanks for the answers.

I forgot a very important field of the table, "production order".

It can occur in 2 different production orders, used to produce the same product, different amounts of raw material are used.

In this way the amount of raw material used in each production order would be different.

 

PO.JPG

Hi,

In another column, Ssow the exact result you are expecting.  Also, share your data in a format that can be pasted in an Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

I cannot download your workbook from that link.  Share the link from where i can download your workbook and please ensure that the expected result column is formula driven so that i can understand the logic.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Follow the link

 

https://docs.google.com/spreadsheets/d/e/2PACX-1vSau7otZ-Ep1KSptceJUHXrFXP8WzQ-Orqx6Xg-m-ytEypIupjb7...

 

 

Sorry. The logic is the same as I described earlier, I just forgot to mention the Production Order field.

That link leads to an error page.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
AlB
Super User
Super User

Hi @ThiagoMi88 

Create a new calculated column in the table you show:

 

NewCalcColumn =
IF (
    Table1[Product] <> Table1[Component],
    DIVIDE (
        Table1[Component],
        LOOKUPVALUE (
            Table1[Amount],
            Table1[Product], Table1[Product],
            Table1[Component], Table1[Product]
        )
    )
)

 

Hi @AlB 

 

Thanks for the sugestion.

 

I tried to apply the formula that passed me, but it is displaying the following error:

 

A multi-valued table was provided, and a single value was expected.

works fine on my end with the example provided. If you get that error you probably have more than one row with Product and Component = 'Pro11'

 

You're right, there's another column called "production order". There may be more than one combination 
Product and Component = 'Pro11'.

I tried:

NewCalcColumn =
IF (
    Table1[Product] <> Table1[Component],
    DIVIDE (
        Table1[Amount],
        LOOKUPVALUE (
            Table1[Amount],
Table1[PO], Table1[PO], Table1[Product], Table1[Product], Table1[Component], Table1[Product] ) ) )

But didn't work.




Helpful resources

Announcements
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.