Excel උදව්වක් දෙන්න පුළුවන් කව්ද ඉන්නේ

wqe123

Well-known member
  • Aug 21, 2015
    8,228
    10,905
    113
    ලංකාවේ.. ලංකාවේ
    පහත රුපයේ තියනවා වගේ ටේබල් එකක් තියනවා. (B2:F7)
    එකේ cost1 සහ cost2 කියන දෙකේ එක එක invoice එකට අදාළ value ත් තියනවා.

    වෙන්න ඕනා පහල තියන දෙවැනි table හදාගන්න ඕනා. එකට cost1 සහ cost2 කියන values apportion කරන්න ඕනා එක එක item එකෙන් item එකට. නමුත් apportion කරන්න වෙන criteria වෙනස්.

    අන්තිමට දෙවැනි table එකට pivot එකක් ගැහුවොත් පලව්වෙනි table එකේ values ගන්න පුළුවන් වෙන්නත් ඕනා. ඒ කියන්නේ දෙකේම එකම දේ. පහල එක details තියෙන්න ඕනා.

    ඔය මම දාලා තියෙන්නේ මට හිතුන හොදම එක. ඊට වඩා සරල සහ straight forward ක්‍රමයක් කියන්න පුළුවන් ද


    1726561440831.png


    Thank you.
    :love:
     
    • Like
    Reactions: sylvaticus

    your_love

    Well-known member
  • Apr 7, 2012
    13,732
    1
    10,626
    113
    The approach you're using is based on distributing `Cost1` and `Cost2` values proportionally across items by their weights (for Cost1) and units (for Cost2), which is sound. However, simplifying or optimizing the method for clarity and ease of understanding is possible by focusing on two main things:

    1. **Cost Distribution Based on Kg (Weight)**:
    For `Cost1`, it seems you're distributing costs based on the total weight (`Total KG`) in proportion to the individual item’s weight.

    2. **Cost Distribution Based on Units**:
    For `Cost2`, you're distributing costs based on the total number of units.

    ### A Simpler Formula:
    You can reduce the complexity by dividing the total cost (`Cost1` or `Cost2`) by the total `Kg` or `Units` once, instead of using SUMIF in the denominator multiple times. Here's a straightforward approach:

    #### **For `Cost1` (Apportion by Kg):**
    - Instead of using the SUMIF formula to get the total weight repeatedly, calculate the total weight for each invoice once and store it in a helper column.

    Formula in the helper column (for `Total Kg`):
    - `=SUMIF($B$3:$B$6, B11, $C$3:$C$6)`

    Then, in `Cost1`:
    - `=(VLOOKUP(B11, $B$3:$E$6, 4, FALSE) / <Total_Kg_for_this_Invoice>) * C11`

    This simplifies to:
    - `=VLOOKUP(B11, $B$3:$E$6, 4, FALSE) / <HelperColumnValue> * C11`

    #### **For `Cost2` (Apportion by Units):**
    - Similarly, instead of recalculating the sum of units for each invoice, use the helper column to store the total number of units.

    Formula in helper column (for `Total Units`):
    - `=SUMIF($B$3:$B$6, B11, $D$3:$D$6)`

    Then, in `Cost2`:
    - `=(VLOOKUP(B11, $B$3:$F$6, 5, FALSE) / <Total_Units_for_this_Invoice>) * D11`

    This simplifies to:
    - `=VLOOKUP(B11, $B$3:$F$6, 5, FALSE) / <HelperColumnValue> * D11`

    ### Pivot Table Compatibility
    Ensure that the final table (`P001-P0019`) matches the structure of the first table, and when you create a pivot table:
    - `Total Cost1` should equal the sum of apportioned `Cost1`.
    - `Total Cost2` should equal the sum of apportioned `Cost2`.

    ### In Summary:
    1. Use helper columns to pre-calculate total Kg and Units per invoice, simplifying formulas.
    2. Apply the apportioning formula to each row without repeatedly calculating totals within the formula.

    By storing intermediate results (e.g., total Kg and total Units) in a helper column, the formulas will be clearer and potentially faster, especially in large datasets.

    Let me know if you'd like me to demonstrate how this would look or if you need any further adjustments! (Powered by Chatgpt)
     

    wqe123

    Well-known member
  • Aug 21, 2015
    8,228
    10,905
    113
    ලංකාවේ.. ලංකාවේ
    The approach you're using is based on distributing `Cost1` and `Cost2` values proportionally across items by their weights (for Cost1) and units (for Cost2), which is sound. However, simplifying or optimizing the method for clarity and ease of understanding is possible by focusing on two main things:

    1. **Cost Distribution Based on Kg (Weight)**:
    For `Cost1`, it seems you're distributing costs based on the total weight (`Total KG`) in proportion to the individual item’s weight.

    2. **Cost Distribution Based on Units**:
    For `Cost2`, you're distributing costs based on the total number of units.

    ### A Simpler Formula:
    You can reduce the complexity by dividing the total cost (`Cost1` or `Cost2`) by the total `Kg` or `Units` once, instead of using SUMIF in the denominator multiple times. Here's a straightforward approach:

    #### **For `Cost1` (Apportion by Kg):**
    - Instead of using the SUMIF formula to get the total weight repeatedly, calculate the total weight for each invoice once and store it in a helper column.

    Formula in the helper column (for `Total Kg`):
    - `=SUMIF($B$3:$B$6, B11, $C$3:$C$6)`

    Then, in `Cost1`:
    - `=(VLOOKUP(B11, $B$3:$E$6, 4, FALSE) / <Total_Kg_for_this_Invoice>) * C11`

    This simplifies to:
    - `=VLOOKUP(B11, $B$3:$E$6, 4, FALSE) / <HelperColumnValue> * C11`

    #### **For `Cost2` (Apportion by Units):**
    - Similarly, instead of recalculating the sum of units for each invoice, use the helper column to store the total number of units.

    Formula in helper column (for `Total Units`):
    - `=SUMIF($B$3:$B$6, B11, $D$3:$D$6)`

    Then, in `Cost2`:
    - `=(VLOOKUP(B11, $B$3:$F$6, 5, FALSE) / <Total_Units_for_this_Invoice>) * D11`

    This simplifies to:
    - `=VLOOKUP(B11, $B$3:$F$6, 5, FALSE) / <HelperColumnValue> * D11`

    ### Pivot Table Compatibility
    Ensure that the final table (`P001-P0019`) matches the structure of the first table, and when you create a pivot table:
    - `Total Cost1` should equal the sum of apportioned `Cost1`.
    - `Total Cost2` should equal the sum of apportioned `Cost2`.

    ### In Summary:
    1. Use helper columns to pre-calculate total Kg and Units per invoice, simplifying formulas.
    2. Apply the apportioning formula to each row without repeatedly calculating totals within the formula.

    By storing intermediate results (e.g., total Kg and total Units) in a helper column, the formulas will be clearer and potentially faster, especially in large datasets.

    Let me know if you'd like me to demonstrate how this would look or if you need any further adjustments! (Powered by Chatgpt)
    this is the exactly same what i did isnt it ?

    But i did not notice following, if i can keep cost/Per Kg and cost/Per Qty calculated table one, it will speed up on large database. i missed it.
     

    vgp

    Well-known member
  • Aug 19, 2010
    1,927
    1,729
    113
    උබට ඕන කරන දේ වෙලා නේ තියෙන්නේ. ඇයි තව සරල ක්‍රම