Forum Discussion

Oros's avatar
Oros
Icon for Post Prodigy rankPost Prodigy
3 years ago
Solved

KPI negative number in parenthesis

Hello,
This measure does not seem to work when the number is negative.
Is it because the negative number is enclosed with parenthesis?
If it's a positive number, it shows the text "UP BY"
But if it's a negative number, it does not change.
 
Is there anything wrong with the measure below? Thanks.
 
KPI =
SWITCH(
    TRUE(),
    [SALES] < 0, "DOWN BY:", "UP BY:"
)
  • Hi Oros ,

     

    If parenthesis is the case then you could try below code:-

    var _remove_open_bracket = SUBSTITUTE([Sales],"(","")
    var _remove_close_bracket = int(SUBSTITUTE(_remove_open_bracket,")",""))
    return
    SWITCH(
        TRUE(),
        _remove_close_bracket < 0, "DOWN BY:", "UP BY:"
    )

2 Replies

  • Samarth_18's avatar
    Samarth_18
    Icon for Community Champion rankCommunity Champion

    Hi Oros ,

     

    If parenthesis is the case then you could try below code:-

    var _remove_open_bracket = SUBSTITUTE([Sales],"(","")
    var _remove_close_bracket = int(SUBSTITUTE(_remove_open_bracket,")",""))
    return
    SWITCH(
        TRUE(),
        _remove_close_bracket < 0, "DOWN BY:", "UP BY:"
    )