Forum Discussion
ybatistamayo
6 years agoHelper III
RELATIONSHIP
I have two tables, one of "Cost" and one of "Taxes", in the latter the "tax" column is updated every year. also the column that I have to relate both tables is "IDCOST". The first problem is that I...
- 6 years ago
That file has an extension of .7z. I cannot open that on my system.
- 6 years ago
hi, ybatistamayo
For your case, you don't need to create the relationship between two tables, just try this formula to create a measure:
Result = var _table=ADDCOLUMNS(COST,"_Tax",CALCULATE(SUM(TAX[TAX]),FILTER(TAX,COST[IDCOST]=TAX[IDCOST]&&YEAR(COST[DATE])=YEAR(TAX[DATE])))) return SUMX(_table,[QUANTITY]*[PRICE]+[_Tax])
Result:
and here is sample pbix file, please try it.
Regards,
Lin
v-lili6-msft
6 years agoCommunity Support
hi, ybatistamayo
For your case, you don't need to create the relationship between two tables, just try this formula to create a measure:
Result = var _table=ADDCOLUMNS(COST,"_Tax",CALCULATE(SUM(TAX[TAX]),FILTER(TAX,COST[IDCOST]=TAX[IDCOST]&&YEAR(COST[DATE])=YEAR(TAX[DATE])))) return SUMX(_table,[QUANTITY]*[PRICE]+[_Tax])
Result:
and here is sample pbix file, please try it.
Regards,
Lin
- ybatistamayo6 years agoHelper III
Excellent!, it worked perfect. Could you explain to me what exactly this calculation is doing?