admin管理员组

文章数量:1122846

Data Table:

Color Amount
Red 5
Blue 3
Red 5
Blue 6

Data Table:

Color Amount
Red 5
Blue 3
Red 5
Blue 6

Main Table:

Color Count
Red 10
Blue 9
Green 0

Hello I have two tables that deal with gumballs let's say, and I am trying to make a calculated column called "Count" in my Main Table that will basically sum all the amounts of gumballs from Data Table grouped by color. Data Table is available to me, and I am showing what I want the Main Table to look like.

What I tried so far: I established a one to many relationship in modal view for color in main table to color in data table.

Count = 
    CALCULATE(
        SUM(RELATED(DATA_TABLE[Amount])),
        MAIN_TABLE[Color] = RELATED(DATA_TABLE[Color])
    ) 

This is the DAX expression I tried but anything after "Related" is underlined red and it says "Parameter is not the correct type / Cannot find name '[Amount]' / Cannot find name '[Color]'" and now I'm not sure what to do. I am making this calculated column in the Main Table.

Share Improve this question asked Nov 22, 2024 at 16:26 Cur FromskyCur Fromsky 273 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

make sure you have created the relationship between two tables and try this to create a column

Column = CALCULATE( sum('Data'[Amount]))+0

本文标签: