Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Help with Case or if statement

I am getting control statement error. If this can be written in if statement or case anything should be fine. if possible can anyone send in qvw file.

@

Script :

let vDEPT_EXCLUSIONS='CAPITAL_PROJECTS';  // if this variable is equal to CAPITAL_PROJECTS then it will have project id filters in the script or else no Project ID filter will be there 

let vProjectID=4;

let vDEPT_EXCLUSIONS=CAPITAL_PROJECTS;

Switch $(vDEPT_EXCLUSIONS)

Case 'CAPITAL_PROJECTS'

[Dimensions Self Service]:

LOAD * INLINE [

        _Dimension, _DimensionID  

        Account, 1

        Account Name, 2

        Account Node3, 3 

        Account Node4, 4

        Account Node5, 5   ]

;

Default

Dimensions Self Service]:

LOAD * INLINE [

        _Dimension, _DimensionID  

        Account, 1

        Account Name, 2

          ]

;

End Switch

EXIT SCRIPT;

1 Solution

Accepted Solutions
maxgro
MVP
MVP

let vDEPT_EXCLUSIONS='CAPITAL_PROJECTS';  // if this variable is equal to CAPITAL_PROJECTS then it will have project id filters in the script or else no Project ID filter will be there

let vProjectID=4;

IF ('$(vDEPT_EXCLUSIONS)'='CAPITAL_PROJECTS') THEN

// 5 rows

[Dimensions Self Service]:

LOAD * INLINE [

        _Dimension, _DimensionID 

        Account, 1

        Account Name, 2

        Account Node3, 3

        Account Node4, 4

        Account Node5, 5   ]

;

ELSE

// 2 rows

[Dimensions Self Service]:

LOAD * INLINE [

        _Dimension, _DimensionID 

        Account, 1

        Account Name, 2

          ]

;

ENDIF

View solution in original post

7 Replies
maxgro
MVP
MVP

maybe



[Dimensions Self Service]:


instead of

Dimensions Self Service]:

Anonymous
Not applicable
Author

Massimo that was not the problem either i will attach the QVW file let me do that

Anonymous
Not applicable
Author

How are you Massimo long time . technically i should get 4 rows but i am getting 2 rows . even if we use IF statement also i am fine with that

maxgro
MVP
MVP

replace

Switch $(vDEPT_EXCLUSIONS)

with

Switch '$(vDEPT_EXCLUSIONS)'

I get 5 rows

Anonymous
Not applicable
Author

Massimo can we get the same output with if statement can you please provide me the script sorry for a direct  question. For some reason i cannot get it to work

maxgro
MVP
MVP

let vDEPT_EXCLUSIONS='CAPITAL_PROJECTS';  // if this variable is equal to CAPITAL_PROJECTS then it will have project id filters in the script or else no Project ID filter will be there

let vProjectID=4;

IF ('$(vDEPT_EXCLUSIONS)'='CAPITAL_PROJECTS') THEN

// 5 rows

[Dimensions Self Service]:

LOAD * INLINE [

        _Dimension, _DimensionID 

        Account, 1

        Account Name, 2

        Account Node3, 3

        Account Node4, 4

        Account Node5, 5   ]

;

ELSE

// 2 rows

[Dimensions Self Service]:

LOAD * INLINE [

        _Dimension, _DimensionID 

        Account, 1

        Account Name, 2

          ]

;

ENDIF

maxgro
MVP
MVP

let vDEPT_EXCLUSIONS='CAPITAL_PROJECTS';  // if this variable is equal to CAPITAL_PROJECTS then it will have project id filters in the script or else no Project ID filter will be there

let vProjectID=4;

Switch '$(vDEPT_EXCLUSIONS)'

Case 'CAPITAL_PROJECTS'

[Dimensions Self Service]:

LOAD * INLINE [

        _Dimension, _DimensionID 

        Account, 1

        Account Name, 2

        Account Node3, 3

        Account Node4, 4

        Account Node5, 5   ]

;

Default

[Dimensions Self Service]:

LOAD * INLINE [

        _Dimension, _DimensionID 

        Account, 1

        Account Name, 2

          ]

;

End Switch