Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
vinay_bangari
Valued Contributor III

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
MVP
MVP

Re: Help with Case or if statement

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

7 Replies
MVP
MVP

Re: Help with Case or if statement

maybe



[Dimensions Self Service]:


instead of

Dimensions Self Service]:

vinay_bangari
Valued Contributor III

Re: Help with Case or if statement

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

vinay_bangari
Valued Contributor III

Re: Help with Case or if statement

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

MVP
MVP

Re: Help with Case or if statement

replace

Switch $(vDEPT_EXCLUSIONS)

with

Switch '$(vDEPT_EXCLUSIONS)'

I get 5 rows

vinay_bangari
Valued Contributor III

Re: Help with Case or if statement

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

MVP
MVP

Re: Help with Case or if statement

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

MVP
MVP

Re: Help with Case or if statement

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

Community Browser