Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calculate percentage %

Hello PowerBI Community 😁

 

I'm new with PowerBI, query, & Stuffs. & I need help with something.

 

So, i want to calculate this column, into percentage %

The logic is, i want to divide every result with /20 and change it to percentage %, but i dont want to calculate "none" result. 
for example: if the result is "20" it's should be "100%"

I've tried this, made a new measurement, but it's not work for me.


*Info
Before i make the safety column, i've to define every result & adding new column with this,

 

Should i convert this column first into interger or something? then i can make a new measurement from it?

 

Any help will be appreciated 🙏

  • Hi Anonymous :

     

    Create a column as below:

    column = 
    var _convert=IF('Table'[Safety(20)]="None",0,'Table'[Safety(20)])
    Return
    DIVIDE(CONVERT(_convert,INTEGER),20)

    And you will see:

    See attached for the related .pbix file.

     


     
    Best Regards,
    Kelly
    Did I answer your question? Mark my post as a solution!
     

9 Replies

  • vanessafvg's avatar
    vanessafvg
    Icon for Community Champion rankCommunity Champion
    you will need to convert it into an integer if you want to do calculations on it, or a number data type, it cannot work with mixed types in a calculation, consider duplicating the column and changing none to 0 if that fits in with your logi
    • Anonymous's avatar
      Anonymous
      Not applicable

      vanessafvg 

      I've changed the "None" with 0 and changed the type into "whole Number"

       

      Then, when i get back to my new measurement its still give me this error

       

       

      how do i fix this?

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

         

        Staff KRa - Safety2 = IF(MAX('Productivity and Task Organization[Staff KRA - Safety New]) = 0, BLANK(), DIVIDE(MAX('Productivity and Task Organization[Staff KRA - Safety New]), 20)

         

        Regards,

        Harsh Nathani

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

     

    IF [Safety] is a measure

     

    New Measure = 

    IF (MAX('Table[Safety]) = "None", BLANK(), CONVERT(MAX(Table[Safety]),INTEGER)

     

     

    If [Safety] is a Column

     

    New Column = IF ('Table[Safety] = "None", BLANK(), CONVERT(Table[Safety],INTEGER)

     

     

    Then change the formatting to Percentage from the top ribbon.

     

    Regards,
    Harsh Nathani

    Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)