Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
petergassert
Contributor III
Contributor III

Variable transfering Data with $1 to set analysis do not return value =

Hi,

i am stuck in a strange behaviour. 
A variable with a parameter value: $(v_FCV_CycleSort_Transfer(MP_2021_01)) is given.

In v_FCV_CycleSort_Transfer the following formula was implemented:  = max({1<FCVersion={"$1"}>} CycleSort2)
to return the respective Value in the order. If I leave the the = away the formula is working fine, but actually i need the retrn value for further processing.

Adjustments to the formula work fine as well, but this is not needed.
=max({1<FCVersion={"$(=GetFieldSelections(FCVersion))"}>} CycleSort2)*/

What am i doing wrong in passing the value along?

May aim is to pass the number that returns the value in a second variable(not mentioned and only works with the value returned here).

DATA:
LOAD * inline
[
FCVersion,CycleSort2
A_Laufend,1
B_IST,0
MP_2021_01,3
MP_2021_02,2
];

2 Solutions

Accepted Solutions
marcus_sommer

The starting = means that the right side is evaluated at once and the result is assigned to the variable. Without the starting = the string of the expression is assigned to the variable.

If I understand you right you tries to nest variables. In general it's possible but it has some restrictions, for example the variables must have no own commas because they would be treated as parameter-delimiter for the variable and not as part of an expressions. Any included and/or needed $-sign expansion like $(=anything) means that those part is calculated globally and won't react on any dimensional context of your object. Further you need to be very carefully with any included comments.

Beside the mentioned restrictions the variable-handling depends either on the content (string, numeric, expression) as well as the kind and place where it's called - and nesting variables could become very complex, much more as might be sensible because the main-aim of variables is to simplify things ...

- Marcus

View solution in original post

marcus_sommer

Maybe it's the number format of your inner variable - if it's not specially defined it will take the default number format of the application and if here is a comma as decimal/thousand-delimiter set the outer variable will take it as an own parameter-delimiter and mostly fail respectively return wrong results.

The approach to use a variable with parameters is often really helpful to avoid redundancies and keep the thing simple and I do it quite often but nesting there further variables which aren't simply a string or a number else which should be also evaluated is definitely tricky to impossible (at least not without bigger changes in the logic and/or to create workarounds which replace other workarounds to ...).

- Marcus

View solution in original post

4 Replies
marcus_sommer

The starting = means that the right side is evaluated at once and the result is assigned to the variable. Without the starting = the string of the expression is assigned to the variable.

If I understand you right you tries to nest variables. In general it's possible but it has some restrictions, for example the variables must have no own commas because they would be treated as parameter-delimiter for the variable and not as part of an expressions. Any included and/or needed $-sign expansion like $(=anything) means that those part is calculated globally and won't react on any dimensional context of your object. Further you need to be very carefully with any included comments.

Beside the mentioned restrictions the variable-handling depends either on the content (string, numeric, expression) as well as the kind and place where it's called - and nesting variables could become very complex, much more as might be sensible because the main-aim of variables is to simplify things ...

- Marcus

petergassert
Contributor III
Contributor III
Author

Thanks Markus for the detailed reply.

You understood my purpose right, that I want to nest variables, as i do want to avoid to place multiple times the same formula, only my parameter is changing only slightly. To store the formula in a Measure already happened but for this case i need to request the result of one value beloning to one value passed to the formula.  Multiple entries are not given in my case. 

I will take your ideas in consideration. But one last question is, what did i do wrong in the upper formula, that no value will be reurned with =, if i pass one value along? 

marcus_sommer

Maybe it's the number format of your inner variable - if it's not specially defined it will take the default number format of the application and if here is a comma as decimal/thousand-delimiter set the outer variable will take it as an own parameter-delimiter and mostly fail respectively return wrong results.

The approach to use a variable with parameters is often really helpful to avoid redundancies and keep the thing simple and I do it quite often but nesting there further variables which aren't simply a string or a number else which should be also evaluated is definitely tricky to impossible (at least not without bigger changes in the logic and/or to create workarounds which replace other workarounds to ...).

- Marcus

petergassert
Contributor III
Contributor III
Author

Hi Markus, 
thanks for the hints in your last two replys.  
the number formating especially comma is a challange itself
Thanks and regards,
Peter