Forum Discussion
Measure to sum values from 2 different columns considering different status
- 5 years ago
Hi Anonymous
You need to be more specific. What is the expected result for the data above?
Try
Measure = SUMX ( Table1, IF ( Table1[Status] = "Indemnified", Table1[PaidValue], IF ( Table1[Status] = "Pending", Table1[EstimatedLoss] ) ) )Please accept the solution when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
- 5 years ago
In general, it's better to use filters than IFs inside of an iterator. So I'd suggest an alternative:
NewMeasure = CALCULATE ( SUM ( Table1[Payed Value] ), FILTER ( Table1, Table1[Status] = "Indemnified" ) ) + CALCULATE ( SUM ( Table1[Estimated Loss] ), FILTER ( Table1, Table1[Status] = "Pending" ) )
Hi Anonymous
You need to be more specific. What is the expected result for the data above?
Try
Measure =
SUMX (
Table1,
IF (
Table1[Status] = "Indemnified",
Table1[PaidValue],
IF ( Table1[Status] = "Pending", Table1[EstimatedLoss] )
)
)
|
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
In general, it's better to use filters than IFs inside of an iterator. So I'd suggest an alternative:
NewMeasure =
CALCULATE (
SUM ( Table1[Payed Value] ),
FILTER ( Table1, Table1[Status] = "Indemnified" )
) +
CALCULATE (
SUM ( Table1[Estimated Loss] ),
FILTER ( Table1, Table1[Status] = "Pending" )
)
- Anonymous5 years agoNot applicable
Thank you so much,
Your suggestion worked very well !!!
- AlB5 years ago
Community Champion
True. IFs within an iterator are usually a drag on performance.
It is also better to filter only on columns rather than on the full table:
NewMeasure V2 = CALCULATE ( SUM ( Table1[Payed Value] ), Table1[Status] = "Indemnified" ) + CALCULATE ( SUM ( Table1[Estimated Loss] ), Table1[Status] = "Pending" )Please accept the solution when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.