Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

IF statement returns 0%

Hi guys,   My previous colleague wrote an Dax If statement to return a percentage of a number. Below you can see the dax statement The problem is that I don't understand this statement. Dax I...
  • Russell-PBI's avatar
    4 years ago

    Hi Anonymous, have you tried just using DIVIDE?:

    ProductivityA = DIVIDE([InvoicingTargetInHours], [NormWorkingHours])

     

  • tackytechtom's avatar
    4 years ago

    Hi Anonymous ,

     

    The reason why it is displaying 0% is due to the first part of your if statement (bold) where it explicitly returns 0 if InvoicingTargetInHours and NormWorkingHours are equal:

    ProductivityA = 
    IF (
    [InvoicingTargetInHours] - [NormWorkingHours] = 0,
    0,
    IFERROR (
    ( [InvoicingTargetInHours] / [NormWorkingHours] ),
    0)
    )

     

    If you would like to diplay 100%, I'd suggest to use the DIVIDE function as Russel-PBI suggested:

    ProductivityA = DIVIDE([InvoicingTargetInHours], [NormWorkingHours])

     

     

    /Tom

    https://www.tackytech.blog/

    https://www.instagram.com/tackytechtom/