cancel
Showing results for
Did you mean:
Anonymous
Not applicable

## 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 If statement:
" ProductivityA = IF([InvoicingTargetInHours] - [NormWorkingHours] = 0, 0, IFERROR(([InvoicingTargetInHours] / [NormWorkingHours]), 0)) "

The measure is calculating the percentage correct if the InvoicingTargetInHours and the NormWorkingHours are different, see picture below:

But once the InvoicingTargetInHours and the NormWorkingHours are the same number, it return 0% when in fact it should return 100% as productivity, see picture below:

Can someone help explain this statement to me and how I should fix this dax?
Should I rewrite or not? Im clueless at this point.

Thanks guys!

2 ACCEPTED SOLUTIONS
Resolver II

Hi @Anonymous, have you tried just using DIVIDE?:

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

Super User

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/

Proud to be a Super User!

2 REPLIES 2
Super User

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/

Proud to be a Super User!

Resolver II

Hi @Anonymous, have you tried just using DIVIDE?:

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

Announcements

#### 2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

#### Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

#### Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

#### Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors