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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Teaman
Frequent Visitor

Sum with relatedtable and Userelationship - circular dependency error referencing a single column

Hi all,

 

I've got a BOL table (list of components and quantites that go together to make a material) and I'm trying to get the total component quantity. I know this is very simple to get with a table in the report view but I need this information as a custom column as other custom columns need to reference it in the future. Below is a simplified version.

BOM

Teaman_1-1655885966370.png


Dim_Material

Teaman_2-1655885987058.png


Relationships

Teaman_0-1655885917693.png


I want the 'Total Quantity' column in Dim_Material to show this

Teaman_3-1655886310322.png


I've tried a few things and I believe the below should work but I'm getting a circular dependency error. The userelationship is required as the actual data includes a lot more data where the dim_material references the BOM_material as the main relationship. This error seems strange to me as it's only referencing one column which is itself - I've search the community and not found any errors like this. 


Teaman_4-1655886392323.png

 

How do I get the total components quantity in this calculated column?

Any help is greatly appreciated.

Thanks,

Greg

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Teaman,

 

Try this calculated column in table Dim_Material. It works with or without relationships.

 

Total Quantity = 
VAR vMaterial = Dim_Material[Material]
// determine if material or component
VAR vType =
    IF (
        ISEMPTY ( FILTER ( BOM, BOM[Material] = vMaterial ) ),
        "Component",
        "Material"
    )
VAR vResult =
    SWITCH (
        vType,
        "Material", SUMX ( FILTER ( BOM, BOM[Material] = vMaterial ), BOM[Quantity] ),
        SUMX ( FILTER ( BOM, BOM[Component] = vMaterial ), BOM[Quantity] )
    )
RETURN
    vResult

 

DataInsights_0-1656264449484.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
DataInsights
Super User
Super User

@Teaman,

 

Try this calculated column in table Dim_Material. It works with or without relationships.

 

Total Quantity = 
VAR vMaterial = Dim_Material[Material]
// determine if material or component
VAR vType =
    IF (
        ISEMPTY ( FILTER ( BOM, BOM[Material] = vMaterial ) ),
        "Component",
        "Material"
    )
VAR vResult =
    SWITCH (
        vType,
        "Material", SUMX ( FILTER ( BOM, BOM[Material] = vMaterial ), BOM[Quantity] ),
        SUMX ( FILTER ( BOM, BOM[Component] = vMaterial ), BOM[Quantity] )
    )
RETURN
    vResult

 

DataInsights_0-1656264449484.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @DataInsights ,

That worked perfectly. Thanks for the help!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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