I want to write a measure on the payment table where:
if(project.status = "active", sum all of payment + project.cost, sum all of payment)
The issue I have is that measure will add the cost 4 times in the sample set below if I write
measure =
SUMX (
payment,
IF (
RELATED ( project[status] ) = "active",
[amount] + RELATED ( project[cost] ),
[amount]
)
)
I can use either table or measure but I can't figure out a way to just pull the project cost once in a measure under the if statement.
Sample data below:
Project
| ID | Cost | Status |
|---|---|---|
| 1 | 50 | Active |
| 2 | 100 | Inactive |
Payment
| Project | Amount |
|---|---|
| 1 | 50 |
| 1 | 100 |
| 1 | 200 |
| 1 | 300 |
| 2 | 50 |
| 2 | 100 |