0

Formalae for Summing products selected

Hi All,

I currently have a Multiple choice field (Show as Radio Buttons) where the staff can select multiple products that the clients has chosen to Purchase.

Example

Hammer - $5

Spanner - $3 

Nails - $10

What formalae should i use to sum up the total cost of the selected products

example the 1 customer bought a hammer = total cost $5

another customer bought a hammer and nails. = total cost $15

Ive been trying if functions but can't seem to wrap my head around it.

1reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
    • Lars
    • Lars
    • 3 mths ago
    • Reported - view

    It depends ... 

    I'd propose to use a dynamic multiple choice (DMC) field 'Multiple Choice' in one table. Then you store your products in another table 'Products'. 'Products' has at least two fields, 'Name' and 'Price'.

    For the DMC, you use "select Products" as dynamic value in the config popup. As name of the dynamic value, you select 'Name'. 

    The total is then 

    let prods := numbers('Multiple Choice');
    let total := 0;
    for i in prods do
        total := total + record('Products',number(i)).Price;
    end;
    total
    Like
Like Follow
  • 3 mths agoLast active
  • 1Replies
  • 19Views
  • 2 Following