Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
stefano27
Contributor II
Contributor II

Dynamic Field name as Variable within Set Analysis

Hello,

I'm trying to evaluate a variable within a set analysis and it does not want to evaluate as it did before the last November Service release. Setup goes as follows:

INLINE table with filed names(@ContributionFN) and Listbox (@ContributionOption) selection

Load * INLINE [

@ContributionNum, @ContributionOption, @ContributionFN

1, 12 Month Option,DSImpactIND12,

2, 18 Month Option,DSImpactIND18,

3, 24 Month Option,DSImpactIND24,];

variable used in set analysis

SET eCMOption =@ContributionFN;

Set Analysis

LET eCYCM   = 'SUM({$<$'&'(eCMOption)'&'={1}>}ContributionMargin)';

So each time a value is selected in the listbox(@ContributionOption) the variable with evaluate for the new selection. I have tried a few options and none seem to work... Encasing the variable in square brackets, or changing the tick marks to chr(39) or listing the variable with no $ expansion. Any help is greatly appreciated. Thank you. 

1 Solution

Accepted Solutions
rubenmarin

Ok, in that case I think you only need to add an equal sign to eCMOption variable:

SET eCMOption = =@ContributionFN; //2 equals, first one to assign value, second to be part of the variable content

View solution in original post

6 Replies
Anil_Babu_Samineni

I really didn't understand, What you are trying. May be Add Equal(=) sign like

LET eCYCM   = '=SUM({$<$'&'(eCMOption)'&'={1}>}ContributionMargin)';

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
rubenmarin

Hi Stefan, by default that expression will sum the contribution margin from records with @ContributionFN=1 (a fixed 1), and I don't see a record with that value.

Maybe it should be SET eCMOption =@ContributionNum; // To show always the 12 month option in eCYCM variable

stefano27
Contributor II
Contributor II
Author

Hi Ruben,

The expression does not evaluate the values inside the set so it just sums the contribution margin. I'm trying to sum up Contribution Margin for the different types of flags in the application (DSImpactIND12, 18, 24) which are 0 or 1. Thank you. 

stefano27
Contributor II
Contributor II
Author

Hi Anil,

I'm trying to sum Contribution Margin for the different DSImpactIND flags. Those can be 0 or 1. Thank you for your answer.

rubenmarin

Ok, in that case I think you only need to add an equal sign to eCMOption variable:

SET eCMOption = =@ContributionFN; //2 equals, first one to assign value, second to be part of the variable content

stefano27
Contributor II
Contributor II
Author

The extra = for the set variable did the trick. Thank you so much for your response and your time and explanation. Regards