Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
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: 

klchan06_1-1645191106029.png

 


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:

 

klchan06_2-1645191159062.png


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
Russell-PBI
Resolver II
Resolver II

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

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

 

View solution in original post

tackytechtom
Super User
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/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

2 REPLIES 2
tackytechtom
Super User
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/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Russell-PBI
Resolver II
Resolver II

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

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

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.