Forum Discussion

Msampedro's avatar
Msampedro
Helper I
10 months ago
Solved

Material Hierarchy / Matrix and duplicate values

Hi there,   Building a matrix based on two tables. Table1 is a material hierarchy, where several final materials belong to one raw material. Table2 I have Qty consumed by raw material. When doing a...
  • v-ssriganesh's avatar
    v-ssriganesh
    9 months ago

    Hello Msampedro,
    Thank you for sharing sample data.

    I reproduced your scenario using your sample tables (Material Mapping and Pivot).
    The duplicate Qty values occurred because each raw material maps to multiple final materials, causing the Qty to repeat at the detailed level.

    To fix this, I created a DAX measure:

    Unique Qty :=
    VAR _Raw = SELECTEDVALUE('Material Mapping'[Raw material])
    RETURN
    IF(
        ISINSCOPE('Material Mapping'[Final Material]),
        BLANK(),
        CALCULATE(SUM('Pivot'[Qty]), 'Pivot'[Material] = _Raw)
    )

    This displays Qty only once per raw material and avoids duplicates under each final material.

    The result matches your expected matrix view (without needing conditional formatting).

    I’ve attached the .pbix file for your reference.

    Best regards,
    Ganesh Singamshetty.