Forum Discussion

MDR's avatar
MDR
Frequent Visitor
3 years ago
Solved

Conditional SUM

I used the following DAX to return total "Approved" amounts across all datanameshorts in my dfact table. When datanameshort is either "SBG" or "SBG10" the total of "Approved" and "Paid" amounts must ...
  • johnt75's avatar
    johnt75
    3 years ago

    The problem is that there is more than value for data name short, so SELECTEDVALUE will return blank.

    Try

    ApprovedAmount =
    IF (
        NOT ISEMPTY ( INTERSECT ( VALUES ( DFACT[DATANAMESHORT] ), { "SBG", "SBG10" } ) ),
        CALCULATE (
            SUM ( DFACT[AMOUNT] ),
            DFACT[DATANAMESHORT]
                IN { "SBG", "SBG10" }
                    && DFACT[STATUS]
                        IN { "Approved", "Paid" } && NOT ISBLANK ( DFACT[GEONAME] )
        ),
        CALCULATE ( SUM ( DFACT[AMOUNT] ), DFACT[STATUS] = "Approved" )
    )