Forum Discussion

SamuelROS's avatar
SamuelROS
Frequent Visitor
3 years ago
Solved

Inconsistent Measure using Switch

Hello Experts, I’m trying to replicate the desired output from a working Calculated column into a measure using switch. Although my per line items are getting the desired result, the totals are a li...
  • Chris_White's avatar
    3 years ago

    Remove the SELECTEDVALUE function from your measure.  MAXX is already converting to row context so having SELECTEDVALUE in there is tripping it up.

    M Age =
    MAXX('DIM_MRF',
        SWITCH(
            TRUE(),
            DIM_MRF[Quantity] = DIM_MRF[QuantityDelivered],
                DATEDIFF(
                    RELATED(DIM_PO[Date].[Date]),
                    DIM_MRF[DeliveryDate].[Date],DAY
                ),
            DIM_MRF[Quantity] <> DIM_MRF[QuantityDelivered],
                DATEDIFF(
                    RELATED(DIM_PO[Date].[Date]),
                    TODAY(),DAY
                )
        )
    )