Platform

Platform

A place for Apptio product users to learn, connect, share and grow together.

 View Only
Expand all | Collapse all

Rounding based on value from another column

  • 1.  Rounding based on value from another column

    Posted 04/17/23 06:17 PM

    I'd like to apply rounding on a column, but apply different decimal points based on value from another column. 

    Looks like Round() function doesn't accept column as an argument .  
    Round(numeric_expression, digits)

    id       value       rounding                 output
    1   100.234                  2                    100.23
    2    0.1239                    3                       0.124

    Thanks
    Prem


    #TBMStudio


  • 2.  RE: Rounding based on value from another column

    Posted 04/18/23 02:25 AM

    Dear Prem,
    assuming you have a finite number of rounding rules (2digits and 3 digits). In this case you could round by each rule (2 intermediate columns) and then decide with an if statement, which result is to be assigned to the final result column (1 extra column). 

    This might appear a little backward but serves as an adequate solution to your problem.



    ------------------------------
    TobiasZimmermannApptioRegional Director Professional Services DACHtzimmermann@apptio.com
    ------------------------------



  • 3.  RE: Rounding based on value from another column

    Posted 04/18/23 04:56 AM
    Edited by Guillermo Cuadrado 11/05/24 06:25 PM


  • 4.  RE: Rounding based on value from another column

    Posted 04/19/23 10:32 AM

    @Prem Kilaru An alternative approach would be to make use of the Eval() function.

    Assuming that your column controlling how many digits to round to is called Rounding, something like the following should work:

    =Round(Amount,Eval("=Rounding"))

    One caveat though, Eval can have significant performance impacts, so please try to avoid doing this on large datasets.



    ------------------------------
    Doug Silk Apptio
    ------------------------------



  • 5.  RE: Rounding based on value from another column

    Posted 04/19/23 11:10 AM

    @Doug Silk Thanks for your input. I'd try this!!
    Just curious is this better or worse than nested if statement?

    Thanks
    Prem




  • 6.  RE: Rounding based on value from another column

    Posted 04/19/23 11:18 AM

    @Doug Silk Just tried, this is not working as well.
    Output is null, same as with using direct column reference. 




  • 7.  RE: Rounding based on value from another column

    Posted 04/24/23 08:48 AM

    @Prem Kilaru That's strange, it should have worked. The following is a test I did:

    Did you include the "=" in the Eval in your test?


    ------------------------------
    Doug Silk - Apptio
    ------------------------------



  • 8.  RE: Rounding based on value from another column

    Posted 04/24/23 12:43 PM

    @Doug Silk Thanks for checking! Below is the error message I'm getting, leaving the column NULL.  It's the same when I create new column instead of updating the existing one. 




  • 9.  RE: Rounding based on value from another column

    Posted 04/18/23 09:30 AM

    @Tobias Zimmermann @Guillermo Cuadrado I have created enhancement request. 




  • 10.  RE: Rounding based on value from another column

    Posted 04/18/23 10:09 AM

    Link to Prem's enhancement request: https://community.ibm.com/community/user/apptio/home




  • 11.  RE: Rounding based on value from another column

    Posted 04/18/23 10:26 AM

    Thank you, @Jenny Franklin . I took a quick look and couldn't find it. Upvoted.



  • 12.  RE: Rounding based on value from another column

    Posted 04/19/23 11:50 AM
    Edited by Dan Kelly 11/05/24 06:34 PM

    It's ugly, but until the RFE is fulfilled you could do something like the following.

    In a table:

    Or in a report:





  • 13.  RE: Rounding based on value from another column

    Posted 04/21/23 10:41 AM

    Thanks, Dan! I have this as fallback approach for time being!!




  • 14.  RE: Rounding based on value from another column

    Posted 04/27/23 12:13 PM

    Finally, casting "Rounding" column explicitly with Value() worked for me. Thanks @Tobias Zimmermann @Guillermo Cuadrado @Jenny Franklin @Doug Silk @Dan Kelly 

    =Round($_, Value(Rounding))

    Thanks!!