Situation:
I have a monetary value that’s consistently the following format… [xxxx][xx] → the last two digits are always the “cents” and anything before them are the dollar amt.
example:
value: 10 = $0.10
value: 100 = $1.00
value: 1300 = $13.00
value: 19912 = 199.12
value: 34920112 = $349,201.12
The goal is a formula which converts the given value into the monetary output.
Here’s what I have that works:
With the output:
Question - surely they’s a simpler way to accomplish this other than the narly substring flow I have now?
${{substring(1.value; 0; length(1.value) - 2)}}.{{substring(1.value; length(1.value) - 2; length(1.value))}}
Here’s the two test modules for a closer look:
{
"subflows": [
{
"flow": [
{
"id": 1,
"module": "util:SetVariables",
"version": 1,
"parameters": {},
"mapper": {
"variables": [
{
"name": "value",
"value": "197753"
}
],
"scope": "roundtrip"
},
"metadata": {
"designer": {
"x": 266,
"y": -16,
"name": "inputs"
},
"restore": {
"expect": {
"variables": {
"items": [
null
]
},
"scope": {
"label": "One cycle"
}
}
},
"expect": [
{
"name": "variables",
"type": "array",
"label": "Variables",
"spec": [
{
"name": "name",
"label": "Variable name",
"type": "text",
"required": true
},
{
"name": "value",
"label": "Variable value",
"type": "any"
}
]
},
{
"name": "scope",
"type": "select",
"label": "Variable lifetime",
"required": true,
"validate": {
"enum": [
"roundtrip",
"execution"
]
}
}
],
"interface": [
{
"name": "value",
"label": "value",
"type": "any"
}
]
}
},
{
"id": 2,
"module": "util:SetVariables",
"version": 1,
"parameters": {},
"mapper": {
"variables": [
{
"name": "get last 2 numbers",
"value": "{{substring(1.value; length(1.value) - 2; length(1.value))}}"
},
{
"name": "all numbers before last 2",
"value": "{{substring(1.value; 0; length(1.value) - 2)}}"
},
{
"name": "combined",
"value": "${{substring(1.value; 0; length(1.value) - 2)}}.{{substring(1.value; length(1.value) - 2; length(1.value))}}"
},
{
"name": "raw value",
"value": "{{1.value}}"
}
],
"scope": "roundtrip"
},
"metadata": {
"designer": {
"x": 575,
"y": -18,
"name": "value of an amt."
},
"restore": {
"expect": {
"variables": {
"items": [
null,
null,
null,
null
]
},
"scope": {
"label": "One cycle"
}
}
},
"expect": [
{
"name": "variables",
"type": "array",
"label": "Variables",
"spec": [
{
"name": "name",
"label": "Variable name",
"type": "text",
"required": true
},
{
"name": "value",
"label": "Variable value",
"type": "any"
}
]
},
{
"name": "scope",
"type": "select",
"label": "Variable lifetime",
"required": true,
"validate": {
"enum": [
"roundtrip",
"execution"
]
}
}
],
"interface": [
{
"name": "get last 2 numbers",
"label": "get last 2 numbers",
"type": "any"
},
{
"name": "all numbers before last 2",
"label": "all numbers before last 2",
"type": "any"
},
{
"name": "combined",
"label": "combined",
"type": "any"
},
{
"name": "raw value",
"label": "raw value",
"type": "any"
}
]
}
}
]
}
],
"metadata": {
"version": 1
}
}