Hi @weird_guy,
Would you be able to elaborate a bit further on what you are trying to do or let me know if I’m headed in the right direction..
So essentially, for a given payment_method, you’d like to run the sum of ‘captured’ amounts (for ‘visa’ for example), divided by the sum of ‘captured’ (for visa)+‘declined’ (for visa)?
Additional questions:
Will the user have an option of selecting the payment method so it will vary based on selection?
When you ask how to transfer ‘state_to’ to ‘Convert to EUR’, what are you trying to do with this and how would you like ‘Convert to EUR’ to come into affect?
So yes, Id like to run the sum of ‘captured’ amounts, divided by the sum of ‘captured’ +‘declined’ and convert it to percent
F.e., we have “captured” 150, “declined” 70. total 220.
150/220 = 0.68
in percent it is 68%
Will the user have an option of selecting the payment method so it will vary based on selection? - No, it happened. Just the finished data already with the completed purchases
When you ask how to transfer ‘state_to’ to ‘Convert to EUR’, what are you trying to do with this and how would you like ‘Convert to EUR’ to come into affect? - here I want to check how many funds are lost (DECLINED) / successful (CAPTURED ) in EUR.
Aha, I got it. Actually I have additional field for each transactions “amount” and “order_id”
So the formula is “status_to” + “order_id” (how many CAPTURED/DECLINED trx) * “amount”
Then * “Convert to EUR” (because I have another filed “currency” . There are a lot of different currencies)
Hi @weird_guy,
In reference to the QS language, unfortunately there’s no documentation that breaks down the error codes you may receive (in my opinion, the error messages could use some updating to help users diagnose the issue better!). In terms of help for learning more about how to better build and utilize the advantages of calculated fields, this is the best article I’ve found for furthering that knowledge!
Looking at your calculation; what is the field type for ‘order_id’, is it a string? If so, I believe that’s where your error is coming in as you’re unable to sum string values. Do you have an additional field in your dataset that contains the amounts you’re trying to sum or are you trying to get gather a count of order id’s?
If trying to utilize a count of order id’s in the calculation, you’ll half to first build out a separate calc. field to complete that; which in that case, I would check out the DistinctCountOver function.
Thank you for your understanding. I’m just new to QS.
I just changed {sales} to {order_id}
In my example, order_id refers to transaction ID - and each order_id has a status of “CAPTURED” or “DECLINED”.
So I’m trying to calculate the approval percentage for each {payment method}.
For example:
A company has had 100 VISA card orders in the last 2 hours.
50 captured/ 50 declined= AR% is 50%.
OR
IF {payment method} = ‘VISA’ THEN ‘ApprovalRate’ = {CAPTURED} {order_id} / {CAPTURED} {order_id} +{DECLINED} {order_id} *100%
Since you’re trying to gather a count of a field that’ s a string, you’ll need to incorporate a calculation that provides you with a count, like distinctCountOver.
Additionally, please check out this article as it explores the order of operations when building calculated fields and can be very valuable in helping out further.