Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
bhavvibudagam
Creator II
Creator II

On Demand App issue

Hi,

kuczynska

saurabhwadhwa

erik.wetterberg

abirami.palanisamy

sureshqv

omarbensalem


Could you please help  me on below On demand Generation App issue.

I am able to generate the  on demand apps from summary app but the selections are not applying in the generated On Demand apps getting total data.


Could you please check the below Template app script once. Please let me know am i missed anything.

1. I have created summary app like below

By reloading getting 10000 records

Main:

LOAD

    APPLICATION,

    CustomerKey,

    SalesOrderNumber,

    SalesOrderLineNumber,

    OrderQuantity,

    DiscountAmount,

    SalesAmount,

    TaxAmt,

    Freight,

    OrderDate,

    ShipDate

FROM [lib://IT Support/1.QVD\1.Extract\A1779.qvd] (qvd);

2. Then created Template App

By reloading getting 0 records. I think we no need to reload the Template app its mentioned in Qlik Help also.


// DO NOT ALTER THIS SUBROUTINE

SUB ExtendQVDWhere(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 mixmatch([$(ColName)],$(Values) )';

    ELSE

        LET WHERE_PART = ' WHERE mixmatch([$(ColName)],$(Values))';

    ENDIF

  ENDIF

END SUB;

// DO NOT ALTER THIS SUBROUTINE

SUB ExtendSQLWhere(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;

// DO NOT ALTER THIS SUBROUTINE

SUB BuildValueList(VarName, TableName, ColName, QuoteChrNum)

  IF ($(QuoteChrNum) = 0) THEN

    LET LOADEXPR = 'Concat($(ColName),' & chr(39) & ',' & chr(39) & ') AS CombinedData';

  ELSE

    LET CHREXPR = ' chr(' & '$(QuoteChrNum)' & ') ';

    LET LOADEXPR = 'Concat( $(CHREXPR) & $(ColName) & $(CHREXPR)' & ',' & chr(39) & ',' & chr(39) & ') AS CombinedData';

  ENDIF

  _TempTable:

  LOAD $(LOADEXPR) Resident $(TableName);

  Let vNoOfRows = NoOfRows('_TempTable');

  IF $(vNoOfRows)> 0 THEN

    LET $(VarName) = Peek('CombinedData',0,'_TempTable');

  ENDIF

  drop table _TempTable;

  drop table '$(TableName)';

END SUB;

//binding Expression

SET App='';

OdagBinding:

LOAD * INLINE [

VAL

$(odo_APPLICATION){"quote": "", "delimiter": ""}

];

SET APP_COLNAME='APPLICATION';

CALL BuildValueList('App', 'OdagBinding', 'VAL', 39); // 39 is for single quote wrapping values

//Where Clause

SET WHERE_PART = '';

FOR EACH fldname IN 'APPLICATION'

  LET vallist = $(fldname);

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

  IF len(vallist) > 0 THEN

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

  ENDIF

NEXT fldname

TRACE Generated WHERE clause: ;

TRACE $(WHERE_PART);

//QVD

Main:

LOAD

    APPLICATION,

    CustomerKey,

    SalesOrderNumber,

    SalesOrderLineNumber,

    OrderQuantity,

    DiscountAmount,

    SalesAmount,

    TaxAmt,

    Freight,

    OrderDate,

    ShipDate

FROM [lib://IT Support/1.QVD\1.Extract\Slaes.qvd] (qvd)

$(WHERE_PART);

But in the Generated app it contains the total data instead of selected data. Please let me know Am i missed anything.

Thanks in advance.

10 Replies
abirami_palanis
Contributor III
Contributor III

Okay. Then you can try below code. 🙂

SUB ExtendSQLWhere(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  ( $(Values) )';

    ELSE

    LET WHERE_PART = '$(Values) ';

    ENDIF

  ENDIF

END SUB;

// DO NOT ALTER THIS SUBROUTINE

SUB BuildValueList(VarName, TableName, ColName, QuoteChrNum)

  IF ($(QuoteChrNum) = 0) THEN

    LET LOADEXPR = 'Concat($(ColName),' & chr(39) & ',' & chr(39) & ') AS CombinedData';

  ELSE

    LET CHREXPR = ' chr(' & '$(QuoteChrNum)' & ') ';

    LET LOADEXPR = 'Concat( $(CHREXPR) & $(ColName) & $(CHREXPR)' & ',' & chr(39) & ',' & chr(39) & ') AS CombinedData';

  ENDIF

  _TempTable:

  LOAD $(LOADEXPR) Resident $(TableName);

  Let vNoOfRows = NoOfRows('_TempTable');

  IF $(vNoOfRows)> 0 THEN

    LET $(VarName) = Peek('CombinedData',0,'_TempTable');

  ENDIF

  drop table _TempTable;

  drop table '$(TableName)';

END SUB;

SET DATE ='';

OdagBinding:

LOAD * INLINE [

VAL

$(ods_DATE){"quote": "", "delimiter": ""}

];

SET DATE_COLNAME='DATE';

CALL BuildValueList('DATE', 'OdagBinding', 'VAL', 39);

SET WHERE_PART = '';

FOR EACH fldname IN 'DATE'

  LET vallist = $(fldname);

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

  IF len(vallist) > 0 THEN

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

  ENDIF

NEXT fldname

TRACE Generated WHERE clause: ;

TRACE $(WHERE_PART);

lib connect to ....

LOAD

DATE

STATUS

POSFLAG;

Sql Select

to_char(DATE,'DD/MM/YYYY')  as DATE,

STATUS,

POSFLAG

where to_char(DATE,'DD/MM/YYYY')  in $(WHERE_PART);