Forum Discussion

Fredde86's avatar
Fredde86
Icon for Advocate I rankAdvocate I
1 year ago
Solved

Calculate not working with one SWITCH statement but with another?

Hi, I have a SWITCH measure that goes like this and it's working like intended:   Status Order *NEW* = SWITCH( TRUE(), ISBLANK( ITEM_TRANSACTION_HISTORY_SUM[NetWorkdays *History*...
  • rajendraongole1's avatar
    1 year ago

    Hi Fredde86 - you can adjust your measures to ensure they work correctly for Ok, Too soon and Too Late measures as below:

    Status (OK) =
    CALCULATE(
    SUM(ITEM_TRANSACTION_HISTORY_SUM[Produced]),
    ITEM_TRANSACTION_HISTORY_SUM[NetWorkdays *History*] IN {-1, 0, 1}
    )

     

    Status (Too soon or Late)

    Status (Too soon / Too late) =
    CALCULATE(
    SUM(ITEM_TRANSACTION_HISTORY_SUM[Produced]),
    ITEM_TRANSACTION_HISTORY_SUM[NetWorkdays *History*] < -1 ||
    ITEM_TRANSACTION_HISTORY_SUM[NetWorkdays *History*] > 1
    )

     

    Calculated columns are evaluated at the row level during data refresh and may not respond dynamically to slicers or other filters applied in the visual. Using measure logic directly avoids this limitation and ensures that the calculations respect the current filter context.

     

    Hope this works.