DonnaTroestler
7 years agoQrew Cadet
Add Euro symbol or the letters EUR to the left of dollar amount in a formula (Part 2)
We have three different Price Lists that we use to create Price Quotes for customers, and we needed to include EUR to the left of European prices. User QuickBaseCoach App Dev./Training developed the following Formula (a Formula - Rich Text field) for me in order to accomplish this (field name is [Price]).
var number PriceToUse = Case([Price List to Use],
"US List Price", [US List Price],
"Asia Dist Price", [Asia Dist Price],
"Asia List Price", [Asia List Price],
"EUR Dist Price", [EU Dist Price],
"EUR List Price", [EU List Price]);
Formula URL field, which does not automatically add a comma to a number or align the number to the right
var number Value = Round($PriceToUse ,0.01);
var text Decimals = "." & Right(ToText(Int($Value * 100)),2);
var text Thousands = If($Value>=1000,ToText(Int($Value/1000)));
var text Hundreds=Right(ToText(Int($Value)),3);
var text Words = List(",",$Thousands,$Hundreds) & $Decimals;
"<div align='right'>"
&
Case([Price List to Use],
"US List Price", "$" & $Words,
"Asia Dist Price", "$" & $Words,
"Asia List Price", "$" & $Words,
"EUR Dist Price", "EUR " & $Words,
"EUR List Price", "EUR " & $Words)
&
"</div>"
However, the next step is that I now I need to take the results of this field and multiply it by the [Quantity] field to get a total for each line item. In spoken words, I need a Formula that does this:
If [Price] contains "EUR " at the beginning of the value, then multiply [Quantity] times everything but the EUR(space), otherwise just multiply [Quantity] times [Price].
I'm not sure what field type would be used (maybe Formula - Numeric?), but what I've got so far for a Formula is this:
If(Contains(Left([Price],3),"EUR "), NotLeft([Price],4), [Quantity]*[everything but EUR(space)],
[Quantity]*[Price])
I may be way off on this, but can anyone help me with the missing piece or piece(s)?
var number PriceToUse = Case([Price List to Use],
"US List Price", [US List Price],
"Asia Dist Price", [Asia Dist Price],
"Asia List Price", [Asia List Price],
"EUR Dist Price", [EU Dist Price],
"EUR List Price", [EU List Price]);
Formula URL field, which does not automatically add a comma to a number or align the number to the right
var number Value = Round($PriceToUse ,0.01);
var text Decimals = "." & Right(ToText(Int($Value * 100)),2);
var text Thousands = If($Value>=1000,ToText(Int($Value/1000)));
var text Hundreds=Right(ToText(Int($Value)),3);
var text Words = List(",",$Thousands,$Hundreds) & $Decimals;
"<div align='right'>"
&
Case([Price List to Use],
"US List Price", "$" & $Words,
"Asia Dist Price", "$" & $Words,
"Asia List Price", "$" & $Words,
"EUR Dist Price", "EUR " & $Words,
"EUR List Price", "EUR " & $Words)
&
"</div>"
However, the next step is that I now I need to take the results of this field and multiply it by the [Quantity] field to get a total for each line item. In spoken words, I need a Formula that does this:
If [Price] contains "EUR " at the beginning of the value, then multiply [Quantity] times everything but the EUR(space), otherwise just multiply [Quantity] times [Price].
I'm not sure what field type would be used (maybe Formula - Numeric?), but what I've got so far for a Formula is this:
If(Contains(Left([Price],3),"EUR "), NotLeft([Price],4), [Quantity]*[everything but EUR(space)],
[Quantity]*[Price])
I may be way off on this, but can anyone help me with the missing piece or piece(s)?