21
Views
7
Comments
Solved
counting all serviceprice record to grandtotal
Question

how can i count all the records from serviceprice to grand total

Bookingsrobbyedit.oml

Solution

Robbie Chandra wrote:

Clarisse Carneiro wrote:


Hi Robbie,

At the moment you have two aggregates: one to display the data of the booking on your popup and the other one to display the data of the room service.

A quick fix is:

     1. Add another aggregate in your preparation. 

     2. In that aggregate do the Sum function aggregating on all the room services price from that bookingId.

     3. Use that aggregate output on the Grand Total Expression + GetBookings(...).Total.

As a performance best practice you should use the SQL tool instead of the aggregate but if you are just starting don't over complicate :)

I hope it helped. If you have any doubt feel free to ask :)

Best regards,

Clarisse

 There are other solutions, like @Zhou Shuai mentioned, counting it on the preparation - using a for each to go through the GetRoomServicesById List and save the data of that counting/sum on a local variable... then you use the local variable on the expression.

See what best fits your case :)

Best regards,

Clarisse

 

 

 How can i use sum in expression? 

 Hi Robbie,


If you use the aggregate scenario:

  1. Create the aggregate, lets name it GetRoomServicesByIdSum (for example)
  2. Do the Sum on the SumServ Column (I think it is on this one that you have the total price per service)
  3. On the Grand Total expression use the aggregate, it should be something like this:
  4. GetRoomServicesByIdSum.List.Current.ServicePriceSum + GetBookingsById.List.Current.Total

If you use the Count option:

  1. Do a for each on the preparation for the record list GetRoomServicesById.List
  2. Create a local variable (example: TotalServices)
  3. On the flow of the preparation set an assign for the TotalServices
  4. In the assign the Total Services will be equal to 
  5. TotalServices = TotalServices + GetRoomServicesById.List.Current.SumServ
  6. With this you are iterating through your RoomServices types, summing each one and storing it on the variable. 
  7. Just use the variable on the Grand total expression:
  8. TotalServices + GetBookingsById.List.Current.Total

 

Here is a picture with both solutions in place, just pick one:



Hope it helped,

Clarisse

Rank: #1006

Hi Robbie,

   You could count it in preparation then show on screen.

Regards,

Zhou Shuai

Hi Robbie,

At the moment you have two aggregates: one to display the data of the booking on your popup and the other one to display the data of the room service.

A quick fix is:

     1. Add another aggregate in your preparation. 

     2. In that aggregate do the Sum function aggregating on all the room services price from that bookingId.

     3. Use that aggregate output on the Grand Total Expression + GetBookings(...).Total.

As a performance best practice you should use the SQL tool instead of the aggregate but if you are just starting don't over complicate :)

I hope it helped. If you have any doubt feel free to ask :)

Best regards,

Clarisse