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: 
Not applicable

extract value from variable?

Hey,

I encountered a problem, hoping I could find some answer here. Right now, I have 6 scenario (1,2,3,4,5,6), and for each scenario I created a variable with the name like vBest_sales_1 (the month with the highest sales under scenario 1).

Raw data and variables are as below:

datescenariosalescustomer #
Sep-13167
Oct-131882
Nov-13184
Sep-132598
Oct-132959
Nov-132773
Sep-133399
Oct-133986
Nov-133889
Sep-134901
Oct-134904
Nov-134648
Sep-135514
Oct-135472
Nov-13593
Sep-136273
Oct-136327
Nov-13620

vBest_Sales_1

Oct-13
vBest_Sales_2Oct-13
vBest_Sales_3Oct-13
vBest_Sales_4Sep-13
vBest_Sales_5Sep-13
vBest_Sales_6Oct-13

Right now, I want to create a table as below:

Scenario123456
sales889598905132
customer #296147

Current approach is to have a dimension which is calles metrix (metrix contains sales, customer #). And then I have 6 expressions (one for each scenario.)

Sample expression:

if(metrix = sales and date = vBest_Sales_1 and scenario =1, sales,

if(metrix= [customer #] and vBest_Sales_1 and scenario =1, [customer# ]))


I need to write 6 expressions for this chart, because for every expression ,the variable name is different. My question is can I use

vBest_Sales_'scenario'  as the variable name? If scenario is 1, then I get the data Oct-13. I tried this. But QV always gives me vBest_Sales_1, not Oct-13.


I am going to expand the scenario to 15. I do not want to write 15 expression, any other ways to do this?


Thanks!!!!!!!

4 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Please find attached file for solution.

Regards,

Jagan.

Not applicable
Author

That's definitely a good solution for this sample simplified problem. But it does not solve my problem. I simplified the problem I am facing right now. But in reality, it is much difficult. Can you answer my question directly like how to extract the value from the variable? That's what I really want to know.

Still, thank you for providing another solution.

jagan
Luminary Alumni
Luminary Alumni

Hi,

I think it is not good practice to hardcode the variables, because the number of scenarios are dynamic, everytime if new scenario is added you need to add variables manually.  I think the solution provided by me is flexible check with your original data.

Regards,

Jagan.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I don't know of any way to do an indirect reference to the variable in your example. However, you could generate a pick() expression in a variable that would return the correct result per Scenario. Do you generate the vBest_Sales_* variables in a script loop? I can show you how to generate the pick() expression but it almost seems easier to generate the values into a table. Any reason you're not creating these values as table fields?


-Rob