# Matrix Report - formula

I'm trying to add a formula to the matrix report in order to count the number of products in an opportunity. Its not working. I'm getting the following error:

"Error: Invalid custom summary formula definition: Incorrect number of parameters for function 'IF()'. Expected 3, received 4."

Formula that I tried:

``````IF(TOTAL_PRICE:SUM = 0,NULL,TOTAL_PRICE:SUM, IF(TOTAL_PRICE:SUM > 0,RowCount,TOTAL_PRICE:SUM))
``````

Try this:

``````IF(TOTAL_PRICE:SUM = 0,NULL,IF(TOTAL_PRICE:SUM > 0,RowCount,TOTAL_PRICE:SUM))
``````

Explanation:

Basic syantx for an If condition is:

``````if(condition,true,false)
``````

You're using an If statement within an If statement. so the synatx would be like this:

``````if(condition,true,(if criteria does not match then u are checking another if condition) if(condition),true,false)
``````

in your formula, if you can see if the total sum is not zero then you are trying to return Total price value then you are again checking the If condition which is syntactically incorrect

• please explain to the OP why he is getting this error and why your code should work, otherwise, please post as a comment. – glls Aug 17 '17 at 17:19
• @glls Please check the updated answer. – Dhananjay Patil Aug 17 '17 at 17:29
• @HUBBY0716 I can see in ur formula u are counting no of products for an opportunity.If you are using matrix report then 'Record Count' which is out of the box field will give you the exact count.You can save ur effort making a new formula.rest is upto u depend on ur requirement. – Dhananjay Patil Aug 17 '17 at 17:32
• @Dhananjay Patil -> Thx! – glls Aug 17 '17 at 17:33