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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
soha1902
Creator
Creator

Load data based on if...else condition

Hi All,

Want to load data based on below condition:

Suppose I have two computers 'A' and 'B' then my load condition should be,

if(ComputerName() = 'A')

Load

       A.Data as DataA

From xyz path;

if(ComputerName() = 'B')

Load

     B.Data as DataB

From xyz path;

Please help me to write this code in QlikView script editor??

1 Solution

Accepted Solutions
sunny_talwar

May be like this:

IF ComputerName() = 'A' then

     FirstLoadHere

ELSEIF ComputerName() = 'B' then

     SecondLoadHere

ENDIF;

View solution in original post

7 Replies
sunny_talwar

May be like this:

IF ComputerName() = 'A' then

     FirstLoadHere

ELSEIF ComputerName() = 'B' then

     SecondLoadHere

ENDIF;

marcus_sommer

Try this:

if ComputerName() = 'A' then

     Load A.Data as DataA From xyz path;

else

     Load B.Data as DataB From xyz path;

end if


- Marcus

soha1902
Creator
Creator
Author

Hi Sunny and Marcus,

Can you please let me what is wrong in this code? why it is showing red line? Please see attached image.

if ComputerName() = 'ATHENA-BLD-02-P' then

Load

     [(PDH-CSV 4.0) (Central Daylight Time)(300)] as Time_Interval

FROM

[$(vDataFile)CPU_RAM_Usage.csv]

(txt, codepage is 1252, embedded labels, delimiter is ',', msq)

elseif ComputerName() = 'B' then

Load

     [(PDH-CSV 4.0) (Eastern Daylight Time)(300)] as Time_Interval

FROM

[$(vDataFile)CPU_RAM_Usage.csv]

(txt, codepage is 1252, embedded labels, delimiter is ',', msq)

endif;

1.png

marcus_sommer

There is a semi-colon missing after the file-format statement.

- Marcus

sunny_talwar

Yes you are missing a semi-color at the end


IF ComputerName() = 'ATHENA-BLD-02-P' then

TableName:

Load

     [(PDH-CSV 4.0) (Central Daylight Time)(300)] as Time_Interval

FROM

[$(vDataFile)CPU_RAM_Usage.csv]

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

ELSEIF ComputerName() = 'B' then

TableName:

Load

     [(PDH-CSV 4.0) (Eastern Daylight Time)(300)] as Time_Interval

FROM

[$(vDataFile)CPU_RAM_Usage.csv]

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

ENDIF;

Kushal_Chawda

Instead of doing this in script why don't you just do conditional on front end.

Lets say you add two dimension

1)  [(PDH-CSV 4.0) (Central Daylight Time)(300)]

     Check enable conditional - if(Computername()='A',1,0)

2)   [(PDH-CSV 4.0) (Eastern Daylight Time)(300)]

      Check enable conditional - if(Computername()='B',1,0)

santiago_respane
Specialist
Specialist

I don't think you can solve that with the computerName() function, it will never return more than computer name per execution, unless you change your .qvw from one computer to another in the middle of the execution.

Do you have one application per computer?

Kind regards,