Forum Discussion
Calculating column values based on two columns and problem in fetching last row's calculation
- Anonymous4 years ago
Hi ankit_cd ,
Since you did not give a specific table, I had to create my own table for testing according to your description, please point out if there are any problems.
Please try below steps:
1. Below is my test table
Table1:
Table2:
2. In "Table2", add a new column with below dax formula
Total Cost = VAR cur_year = Table2[Year] VAR type_cost = "Fixed" VAR tmp = FILTER ( ALL ( Table1 ), Table1[Type of cost] = type_cost && YEAR ( Table1[Year] ) = cur_year ) RETURN SUMX ( tmp, [Cost] )Please refer the attached .pbix file.
Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi ankit_cd ,
Since you did not give a specific table, I had to create my own table for testing according to your description, please point out if there are any problems.
Please try below steps:
1. Below is my test table
Table1:
Table2:
2. In "Table2", add a new column with below dax formula
Total Cost =
VAR cur_year = Table2[Year]
VAR type_cost = "Fixed"
VAR tmp =
FILTER (
ALL ( Table1 ),
Table1[Type of cost] = type_cost
&& YEAR ( Table1[Year] ) = cur_year
)
RETURN
SUMX ( tmp, [Cost] )
Please refer the attached .pbix file.
Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.