Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Error in Expression ')' expected

Receiving Error in Expression ')' expected.

The script I'm trying to run is:

Set calcBidPercent = 'if(FCST = 0, 0, DAMW/FCST)';

Set calcLoadZeroBid = 'round((FCST*.00*DALMP)+(((fabs(RTMTR)-(FCST*.00))*RTLMP)),0)';

Set calcDverZeroBid = 'round(((FCST*.00*DALMP)+((FCST*.00)- RTMTR)*RTLMP )*-1,0)';

//Set calcBidPercentZero = 'if($(calcBidPercent) = 0, 0, if(TYPE = 'LOAD',$(calcLoadZeroBid), $(calcDverZeroBid)))';

Set calcLoad50Bid = 'round((FCST*.50*DALMP)+(((fabs(RTMTR)-(FCST*.50))*RTLMP)),0)';

Set calcDver50Bid = 'round(((FCST*.50*DALMP)+((FCST*.50)- RTMTR)*RTLMP )*-1,0)';

//Set calcBidPercent50 = 'if((calcBidPercent) = 0, 0, if(TYPE = 'LOAD', (calcLoad50Bid), (calcDver50Bid)))';

Set calcLoad80Bid = 'round((FCST*.80*DALMP)+(((Fabs(RTMTR)-(FCST*.80))*RTLMP)),0)';

Set calcDver80Bid = 'round(((FCST*.80*DALMP)+((FCST*.80)- RTMTR)*RTLMP )*-1,0)';

//Set calcBidPercent80 = 'if((calcBidPercent) = 0, 0, if(TYPE = 'LOAD', (calcLoad80Bid),(calcDver80Bid)))';

Set calcLoad100Bid = 'round((FCST*1*DALMP)+(((fabs(RTMTR)-(FCST*1))*RTLMP)),0)';

Set calcDver100Bid = 'round(((FCST*1*DALMP)+((FCST*1)- RTMTR)*RTLMP )*-1,0)';

//Set calcBidPercent100 = 'if((calcBidPercent) = 0, 0, if(TYPE = 'LOAD', (calcLoad100Bid), (calcDver100Bid)))';

Set calcLoad105Bid = 'round((FCST*1.05*DALMP)+(((fabs(RTMTR)-(FCST*1.05))*RTLMP)),0)';

Set calcDver105Bid = 'round(((FCST*1.05*DALMP)+((FCST*1.05)- RTMTR)*RTLMP )*-1,0)';

//Set calcBidPercent105 = 'if((calcBidPercent) = 0, 0, if(TYPE = 'LOAD', (calcLoad105Bid), (calcDver105Bid)))';

Set calcActualSettle = '(RTMW*RTLMP)+(DAMW*DALMP)';

Set calcTraderSettle = 'if($(calcBidPercent) = 0,0,$(calcActualSettle))';

Set calcAmountSavedLoad = '($(calcTraderSettle)- $(calcLoad100Bid)*-1)';

Set calcAmountSavedDver = '($(calcTraderSettle)-$(calcDver50Bid))';

//Set calcAmountSaved = 'if((calcBidPercent) = 0,0,if(TYPE = 'LOAD',(calcAmountSavedLoad),(calcAmountSavedDver)';

Set calcWorstCaseAmountLoad = 'If($(calcLoad80Bid) > $(calcLoad100Bid),$(calcLoad80Bid), $(calcLoad105Bid))';

Set calcWorstCaseAmountDver = 'if($(calcDverZeroBid) < $(calcDver105Bid), $(calcDverZeroBid),$(calcDver105Bid))';

//Set calcWorstCase= 'if(TYPE = 'LOAD', (calcWorestCaseAmountLoad), (calcWorestCaseAmountdver))';

Set calcBestCaseAmountLoad = 'if($(calcLoad80Bid) < $(calcLoad100Bid),$(calcLoad80Bid), $(calcLoad105Bid))';

Set calcBestCaseAmountDver = 'if($(calcDverZeroBid) > $(calcDver105Bid), $(calcDverZeroBid),$(calcDver105Bid))';

//Set calcBestCase = 'if(TYPE = 'LOAD', (calcWorestCaseAmountLoad), (calcWorestCaseAmountdver))';

Set calcBestCaseLoadSaved ='($(calcBestCaseAmountLoad)-$(calcLoad100Bid)*-1)';

Set calcBestCaseDverSaved ='($(calcBestCaseAmountDver)-$(calcDver50Bid))';

//Set calcBestCaseSaved= 'if(TYPE = 'Load',(calcBestCaseLoadSaved),(calcBestCaseDverSaved))';

Set calcWorstCaseLoadSaved ='($(calcWorstCaseAmountLoad)-$(calcLoad100Bid)*-1)';

Set calcWorstCaseDverSaved ='($(calcWorstCaseAmountDver)-$(calcDver50Bid))';

//Set calcWorstCaseSaved= 'if(TYPE = 'Load',(calcWorstCaseLoadSaved),(calcWorstCaseDverSaved))';

CalcFinalData:

  Load

  OPDATE, HE, MINUTE, LOCATION, TYPE, FCST, RTMW, RTLMP, RTMTR, DAMW, DALMP,

  $(calcBidPercent) as BidPer,

  if($(calcBidPercent) = 0, 0, if(TYPE = 'LOAD',$(calcLoadZeroBid), $(calcDverZeroBid))) as [0%],

  if($(calcBidPercent) = 0, 0, if(TYPE = 'LOAD',$(calcLoad50Bid), $(calcDver50Bid))) as [50%],

  if($(calcBidPercent) = 0, 0, if(TYPE = 'LOAD',$(calcLoa80Bid), $(calcDver80Bid))) as [80%],

  if($(calcBidPercent) = 0, 0, if(TYPE = 'LOAD',$(calcLoa100Bid), $(calcDver100Bid))) as [100%],

  if($(calcBidPercent) = 0, 0, if(TYPE = 'LOAD',$(calcLoa105Bid), $(calcDver105Bid))) as [105%],

  $(calcActualSettle) as [Actual Settle],

  $(calcTraderSettle) as [Trader Settle],

  if($(calcBidPercent) = 0,0,if(TYPE = 'LOAD',$(calcAmountSavedLoad),$(calcAmountSavedDver))) as [Amount Saved],

  if(TYPE = 'LOAD', $(calcWorstCaseAmountLoad), $(calcWorstCaseAmountDver)) as [Worst Case],

  if(TYPE = 'LOAD', $(calcBesttCaseAmountLoad), $(calcBestCaseAmountDver)) as [Best Case],

  if(TYPE = 'LOAD', $(calcBestCaseLoadSaved),$(calcBestCaseDverSaved)) as [Best Case Saved],

  if(TYPE = 'LOAD', $(calcWorstCaseLoadSaved),$(calcWorstCaseDverSaved)) as [Worst Case Saved]

  Resident FinalData;

1 Solution

Accepted Solutions
swuehl
MVP
MVP

I assume one or more of your variables does not expand to the correct script code.

Comment out all calculated fields and rerun your script. Enable one line after the other when load is succeeding, hence you should be able to identify the critical variable easily.

Enable the document log or have a close look running the script in debug mode how the variables are expanded to code.

In most cases, it's just a simple typo in spelling the correct variable name..

View solution in original post

6 Replies
NickHoff
Specialist
Specialist

Which variable is causing the error message?

View the variables in a text box to narrow it down.  After that i'll be able to help you further.

rupamjyotidas
Specialist
Specialist

Wow..That's a lot of brackets:-).

I would suggest load one/two variable per line and test the script. Also what Nick  above has suggested works too.

Thanks

rupamjyotidas
Specialist
Specialist

Ans also if any of the Variable line has Aggregation, you need to do a Group BY in the Load statement.

swuehl
MVP
MVP

I assume one or more of your variables does not expand to the correct script code.

Comment out all calculated fields and rerun your script. Enable one line after the other when load is succeeding, hence you should be able to identify the critical variable easily.

Enable the document log or have a close look running the script in debug mode how the variables are expanded to code.

In most cases, it's just a simple typo in spelling the correct variable name..

Not applicable
Author

Set calcActualSettle = '(RTMW*RTLMP)+(DAMW*DALMP)'

Load

(RTMW*RTLMP)+(DAMW*DALMP) as [Actual Settle]

Seems to be the cause of the error

Not applicable
Author

Found several Typo's. Thank you.