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.
To create a calculated column in MAIN_TABLE that sums the AMOUNT from the related DATA_TABLE , grouped by value in the color column . Here's an example of how to create the calculated column : Total_Amount_By_Color = CALCULATE( SUM(RELATED(DATA_TABLE[AMOUNT])), FILTER( DATA_TABLE, DATA_TABLE[color] = MAIN_TABLE[color] ) )