Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
joey_lutes
Partner - Creator
Partner - Creator

Variable Text in Fieldname

I am attempting to insert variable text directly into a fieldname within an expression.

Fieldname Examples:

[KPI AltAvg Parameter]

[KPI AltMax Parameter]

[KPI Avg Parameter]

[KPI Max Parameter]


I have created an inline table:

Load *INLINE [

     Parameter

     AltAvg

     AltMax

     Avg

     Max ];


I've also created a variable called $vParameter that a user can select/set via a selection box.


What I'd like to do is create a measure that looks something like this:

sum('KPI ' & '$(vParameter)' & ' Parameter')


Does this have any chance of working?

Thanks in advance!


1 Solution

Accepted Solutions
sunny_talwar

How about may be this


Sum($(=$(vParam)))


Or


Sum($(=$(=vParam)))

View solution in original post

8 Replies
sunny_talwar

May be try this:

Sum($(='[KPI ' & vParameter & ' Parameter]'))


Sum($(='[KPI ' & Parameter & ' Parameter]'))

joey_lutes
Partner - Creator
Partner - Creator
Author

'[KPI ' & $(vParameter1)& ' ' & 'Parameter]'

in a KPI box does indeed create the correct fieldname  = [KPI AltAvg Parameter]

HOWEVER, if I wrap that statement in sum() it breaks.

I have tried creating a Let vParamString = '[KPI ' & $(vParameter1)& ' ' & 'Parameter]' in the loadscript and also in the variable editor (independently).

Unfortunately, the resulting variables don't populate the values and the result of it is the string entered, not the intended variable-created name.

I've also learned that in creating a select box with the Fieldname in it - when I create the associated variable, I simply enter the fieldname in the description.  If I attempt to use GetFieldSelections(Fieldname) it fails (with or without preceding =).  Leaving just the fieldname does populate the variable accordingly when it is selected, however I'm still unable to get it to work properly

I've scoured the net and apparently no one else wants to do this

Other ideas??

Thanks!

sunny_talwar

I recommended you using the field instead of a variable, did you try this the field Parameter,instead of vParameter?

Sum($(='[KPI ' & Parameter & ' Parameter]'))

joey_lutes
Partner - Creator
Partner - Creator
Author

Ok, using that concept, I was able to construct the string, as well as create a variable that returns the correct result!!  Almost there.

Now I have:

$vParam = '[KPI' & Parameter & ' ' & 'Parameter]'

so in a KPI box, I can show $(vParam) and it will display

[KPI AltMax Parameter]

Perfect, right!?!

So I got greedy and wrapped a sum() around it.  it said 'no'.

I tried:  sum($(=vParam)) as well.

Since the result of this variable I wanted to be taken to be literal, I'm assuming I'm missing some syntax here?

sunny_talwar

How about may be this


Sum($(=$(vParam)))


Or


Sum($(=$(=vParam)))

joey_lutes
Partner - Creator
Partner - Creator
Author

THANK you.  They both actually produced the same, correct result.

I went with the first.  That was a stumper - thanks again!

sunny_talwar

Awesome. I am glad you were able to make this to work. Always a great feeling.


Best,

Sunny

ShippingNews
Contributor
Contributor

so you have to have a variable to place the string in before doing the sum is that correctly understood or can you actually get the sum without first passing the string to the variable? 
I have similar issue and unable to extract the actual field value even when getting the string to look excactly like the field name.