Crystal Reports: Conditional Sums


How can you add certain records that meet a dynamic condition? For example, the user with "ID" = 1 of table "Usuario" has three purchases in table "Compras" . This table "Compras" has three fields: ID_Compra , ID_Usuario and Monto_Compra . How do I do in Crystal Reports to add these three purchases, if there are more than 200 clients and more than 1,000 purchases in my table? How can I group your purchases and not sum up all the fields in the table?

I am using the following formula:


This formula adds up to more than a thousand purchases in the Compras table. I see that Crystal Reports has the option of conditional sums, but I have not found examples of use.

asked by Ricky 07.10.2016 в 23:38

1 answer


If it is a question of adding the amounts of the different Users, then what you should do is create a group by User_ID and pass it to the SUM function as the second parameter:



It is also possible to add only the amounts of the User with "ID_User = 1" (if that is what you referred to with " to be able to add these three purchases only "). In Record Selection Formulas add the following:

{Compras.ID_Usuario} = 1
answered by 13.10.2016 в 16:46