Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
s_santalucia
Contributor

ODAG- scripting model app

Hi,

Is there anyone available to explain how to write the model app script?


Thanks

3 Replies
kakani87
Contributor III

Re: ODAG- scripting

Check with this. May be useful

s_santalucia
Contributor

Re: ODAG- scripting

hi, thank you for your answer, but I want scriptn for ODAG!

its different!

pawwy1415
Contributor II

Re: ODAG- scripting

Hi,

For ODAG need to create two apps

1. one for summary app which is you Final UI app where you will apply selections.

2. Detail app - here need to write the ODAG Script.

if you are working with sql database need to follow the below code just update with your fields everything remains same

// DO NOT ALTER THIS SUBROUTINE

SUB ExtendWhere(Name, ValVarName)

  LET T = Name & '_COLNAME';

  LET ColName = $(T);

  LET Values = $(ValVarName);

  IF len(Values) > 0 THEN

  IF len(WHERE_PART) > 0 THEN

    LET WHERE_PART = '$(WHERE_PART) AND $(ColName) IN ( $(Values) )';

    ELSE

    LET WHERE_PART = ' WHERE $(ColName) IN ( $(Values) )';

    ENDIF

  ENDIF

END SUB;

SET ACCOUNTID= ;

SET ACCOUNTID= $(ods_ACCOUNT);  //this ACCOUNT field name should match with your summary app field

SET ACCOUNTID_COLNAME='a.accountid'; //this a.accountid field name should match with your database field

SET COMPANYID= ;

SET COMPANYID= $(ods_COMPANY);

SET COMPANYID_COLNAME='a.companyid';

SET WHERE_PART = '';

//First Set Statement Variable fields ACCOUNTID, COMPANYID need to pass at For Loop

FOR EACH fldname IN 'ACCOUNTID', 'COMPANYID'

  LET vallist = $($(fldname));

  WHEN (IsNull(vallist)) LET vallist = '';

  IF len(vallist) > 0 THEN

    CALL ExtendWhere('$(fldname)','vallist');

  ENDIF

NEXT fldname

TRACE Generated WHERE clause: ;

TRACE $(WHERE_PART);

LOAD

     1 AS "FLIGHT_COUNT",

     ACCOUNTID as "ACCOUNT",

      COMPANYID as "COMPANY";

 

SQL SELECT

          a.accountid,

          a.companyid

FROM "SAPH7T"."/QT/AIRPORT_FACT"

$(WHERE_PART);