Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
tahirkhalil
Creator
Creator

Using Field Value as Variable Name

Hi,

I am supposed to define a dynamic threshold for compliance values. For that I am using inline table to define variables within the table, which is defined as variable for slicer.

See below the code:

[COMPRULE]:

LOAD * INLINE [

    Variable, Value, StoreType

    Var1, 5, A

    Var2, 3, B

    Var3, 2, C

];

// This is to set default values to variables:

Let x=NoOfRows('COMPRULE')-1;

Trace $(x);

For counter = 0 to NoOfRows('COMPRULE')-1

Trace $(counter);

Let Variable1 = peek('Variable', $(counter));

Let Value = peek('Value', $(counter));

Let $(Variable1) = $(Value);

Trace $(Variable1), $(Value);

Next counter

Now I need to access the corresponding value against each variable for calculation.

Can someone please check the attached doc and suggest me how can I get the value from field and get corresponding value from stored variable name.

11 Replies
settu_periasamy
Master III
Master III

Hi,

check the Attachment. Do you need like that?

maxgro
MVP
MVP

like this? a Var2 slicer between Var3 and Var1?

1.png

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

For a specific StoreType you want to use the value of the corresponding variable?

Pick(

Match(StoreType, 'A', 'B', 'C')

,'$(Var1)','$(Var2)','$(Var3)'

)

-Rob

effinty2112
Master
Master

Hi Tahir,

I'm not sure I understand what you want to do but if what you want is to judge compliance of each store based on a comparison  of each store's score with the compliance rule value for each type of store there is no need to take these compliance rule values and place them into variables. The association on the field [Store Type] makes it straightforward. So straightforward I'm worried that I've totally failed to grasp what you require.

Isn't this the kind of result you want?

StoreType Value Compliance StoreCode Score
A5Yes15
107
166
No42
74
132
192
B3Yes28
83
115
175
No51
141
201
C2Yes34
98
123
158
183
tahirkhalil
Creator
Creator
Author

Hi Settu,

Great - quite helpful but what happened if I have multiple store types - e.g. more than 20? Can you suggest any alternative approach instead of Pick - because sometime these type can be changed and I will have to change the variable every time in that case?

tahirkhalil
Creator
Creator
Author

Right Wob,

But what happened if I have n (unknown) number of store types?

tahirkhalil
Creator
Creator
Author

Hi Andrew,

Yes, in case of tables, there is no issues, the problem arises when I need to change the values ie compliance standard through slicer. I need to see the impact of these changes in compliance. Am I able to clarify the point?

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think Andrew has you on the right track, that is, the Compliance Value  is linked to the StoreType. If you can have more than one ComplianceValue per StoreType, you just need to figure out which one to chose if more than one is possible. You could use Max(ComplianceValue ) or FirstSortedValue(ComplianceValue,..) depending on your business rule.

-Rob

tahirkhalil
Creator
Creator
Author

Hi

I have taken the approach suggested by Settu & Rob.

Now I am stuck up with the button based filter of data. I have created two buttons to list either Compliant and Non-Compliant Stores.

Can someone suggest me how to manage the filters?