Forum Discussion

Applicable88's avatar
Applicable88
Impactful Individual
5 years ago
Solved

Add a string to a number or a decimal format

Hello,

I have a integer column, which is hours in decimal. I just watn to add a "h" for hours.

I know there is a possiblity to do something like

Measure=  containsstring(calculate(sum(Workinghours)), "h")

but this way I have convert the return of that measure into a string, which I cannot put in another calculation. Other than that the big disadvantage is that if I want to make color formatting the colors only applys to the sum of workinghours, but not to the string "h".

So my first question is, if its possible to do it without a measure in the first place, just format it in the "format" field in a certain way.

Or if not how to write better code to get there?

Thank you very much in advance.

 

Best. 

 

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Applicable88 ,

     

    To my knowledge, currently there is no way to add a string to the Time type and still maintain the Time type.

     

    In your case, I suggest you add an another measure to add a "h" text to the original measure. Like this:

    sum Workinghours = CALCULATE(SUM('Table'[Workinghours]),ALLEXCEPT('Table','Table'[ID]))
    Add H to measure = [sum Workinghours] & "h"

    Then you could onditional formatting as well:

     

    An idea similar with what you expect has been submitted in the following link, please vote it up and you can add comments in this idea: Time format [hh]:mm:ss

     

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Applicable88 ,

     

    To my knowledge, currently there is no way to add a string to the Time type and still maintain the Time type.

     

    In your case, I suggest you add an another measure to add a "h" text to the original measure. Like this:

    sum Workinghours = CALCULATE(SUM('Table'[Workinghours]),ALLEXCEPT('Table','Table'[ID]))
    Add H to measure = [sum Workinghours] & "h"

    Then you could onditional formatting as well:

     

    An idea similar with what you expect has been submitted in the following link, please vote it up and you can add comments in this idea: Time format [hh]:mm:ss

     

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.