I’m not sure what exactly you want to calculate in “OutstandingFailures” (put this code in new Table on DATA tab in powerbi:

OutputTable =
SUMMARIZECOLUMNS (
    Manufactur[Manufacturer],
    "TotalSubmissions", COUNTROWS ( Manufactur ),
    "TotalFailed",
        CALCULATE (
            COUNTROWS ( Manufactur ),
            FILTER ( ALL ( Manufactur[TxStatus] ), Manufactur[TxStatus] = "Fail" )
        ),
    "TotalSucceeded",
        CALCULATE (
            COUNTROWS ( Manufactur ),
            FILTER ( ALL ( Manufactur[TxStatus] ), Manufactur[TxStatus] = "Success" )
        ),
    "DistinctPartNoCount", CALCULATE ( DISTINCTCOUNT ( Manufactur[PartNo] ) ),
    "OutstandingFailures",
        VAR _maxDate =
            TREATAS (
                ADDCOLUMNS (
                    VALUES ( Manufactur[ManufacturerPartKey] ),
                    "maxDate", CALCULATE ( MAX ( 'Manufactur'[TxDate] ) )
                ),
                Manufactur[ManufacturerPartKey],
                Manufactur[TxDate]
            )
        RETURN
            CALCULATE (
                COUNTROWS ( Manufactur ),
                FILTER ( ALL ( Manufactur[TxStatus] ), Manufactur[TxStatus] = "Fail" ),
                _maxDate
            ),
    "ReprocessedCount",
        VAR _failure =
            SELECTCOLUMNS (
                FILTER (
                    ALL ( Manufactur[ManufacturerPartKey], Manufactur[TxStatus] ),
                    Manufactur[TxStatus] = "Fail"
                ),
                "Key", Manufactur[ManufacturerPartKey]
            )
        RETURN
            CALCULATE (
                COUNTROWS ( Manufactur ),
                FILTER ( ALL ( Manufactur[TxStatus] ), Manufactur[TxStatus] = "Success" ),
                _failure
            )
)

enter image description here

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top