Crystal Reports: Conditional Sums

0

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:

sum({Compras.Monto_Compra})

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
source

1 answer

1

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:

sum({Compras.Monto_Compra},{Compras.ID_Usuario})

Updated

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