Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
HanhLe
Contributor
Contributor

Switch models when condition matched

Hi community,

I have an app used to monitor price list over time. I want to observe both general situation as well as details by list of products. But because the data is huge, I just take needed information by uploading file included required product code. Hence, I build 2 models in my app:

- Model 1: grouped information used for general visualization

- Model 2: uploaded product list 

Now what I want to know is how to switch between 2 models with the logic: if a product list is uploaded, use model 2 to run all visualization sheets, else use model 1

Is there any way to do so?

Thank you!

Labels (1)
1 Reply
Aditya_Chitale
Specialist
Specialist

if both the models are independent and their script do not depend on each other at all, then you can write an if condition to check if product list file is uploaded at a location and run model 2 script. else run model 1 script.

If the product list is uploaded in excel,  you can use similar logic as below:

let vFilePath='lib://Product list/Prod1.xlsx';

for each file in filelist('$(vFilePath)')

FileList:
load
'$(file)' as FileName,
filetime('$(file)') as FileTime
autogenerate 1

next

let vFileCount = NoofRows('FileList');

// if condition started

if '$(vFileCount)' > 0 then

// Add model 2 code here

else

// Add model 1 code here

endif

 

Regards,

Aditya