Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello guys,
I have created variables with parameters and they're working as expected, except for when the value has a comma ",".
In this case, commas are used to separate the inputs so how can we bypass this issue ?
Example
Hard coded formula:
Variable with Parameters
Thank you in advance
well, I got a workaround working for commas,
First, I added the expression as a variable:
$(teste2(Value,$(testString2)))
Second, I've inputed the testString2 as the string you need, but changed the comma for another character (in my case "|" separator).
Lastly, on the function definition, I used a string replace statment to change the separator, like:
sum({<Teste={"$(=replace($2,'|',','))"}>}$1)
In my screenshot, the last column of the table is the result, getting me the value for the string "Test 1, Test2" after these operations.
You'd have to hardcode the needed set analysis types you need, as I stated on my example
HI Pedro,
Commas work just fine, I believe its the way you set your "function" in the variable, as I understand your passing the types on your second argument to the set analysis.
As an example i used:
data:
Load * Inline
[
Id,Value
1,100
2,333
5,3313
53,111
]
All this expression return values:
1. $(teste(Id,Value))
Expression named "testValue"
2. sum(Value)
3.$(teste(Id,testValue))
I believe you need to encapsulate your second argument in apostrophes (string like) for it to work the way you need.
Hi Felip,
Thank you for your answer.
That is not quite my issue, I understand that the comma is used to separate the fields that I want to use.
My problem is that one of the Field values I want to use as a parameter has a comma: Sales / Observe, Listen
In order to be able to use the variable correctly I need to find a way to have $(QuestionType(2, Sales / Observe, Listen)), in a way that the comma between Observe, Listen is assumed as part of the value and not a separator of the parameters.
Thank you !
what about:
QuestionType = Avg({< Type= {"$1"}, Question = {chr(39) & $2 & chr(39)} >} Weight)
?
well, I got a workaround working for commas,
First, I added the expression as a variable:
$(teste2(Value,$(testString2)))
Second, I've inputed the testString2 as the string you need, but changed the comma for another character (in my case "|" separator).
Lastly, on the function definition, I used a string replace statment to change the separator, like:
sum({<Teste={"$(=replace($2,'|',','))"}>}$1)
In my screenshot, the last column of the table is the result, getting me the value for the string "Test 1, Test2" after these operations.
You'd have to hardcode the needed set analysis types you need, as I stated on my example
The $2 has the commas, and quoting it didn't work on my testing, since it gets only the part of the string before the comma.
Example string: "Test 1, Test2" gets only "Test" as a result since it understands the expansion as two parameters, "Test" and "Test2" ($2 and $3 respectively).
let's try replacing comma symbol with chr(44)
Same story, tested that as well, no luck because its the same situation as I described before.
It's a long running problem/limitation that you can't use a comma in the variable parameter value. It's always interpreted as a parm separator. The only workaround I've found is to use a proxy character as Felip suggested.
-Rob
Hi Felip,
Thank you for your answer
Pedro