Forum Discussion

borniex's avatar
borniex
Frequent Visitor
2 years ago
Solved

Parent child calculation

Hello! It seems like a simple task but I can't figure it out, has anyone encountered this problem? I am attaching a clear example. How can I calculate the two columns?
  • barritown's avatar
    2 years ago

    Hello borniex,

    Assuming, the tables are not related in your data model, I could propose to create a couple of calculated columns like this one:

    In plain text:

    sum_parent = 
    VAR CurrentParent = [parent] 
    RETURN SUMX ( FILTER ( Data, [product] = CurrentParent ), [value] )
    
    sum_child = 
    VAR CurrentChild = [child]
    RETURN SUMX ( FILTER ( Data, [product] = CurrentChild ), [value] )

    Best Regards,

    Alexander

    My YouTube vlog in English

    My YouTube vlog in Russian