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

Announcements
Q&A with Qlik - Qlik Cloud Migration: Questions about migrating to Qlik Cloud? Catch the latest replay!
cancel
Showing results for 
Search instead for 
Did you mean: 
luisccmm
Creator
Creator

IF script function ERROR

HiWhy the following  SCRITP code is FAILING in this "IF" FUNCTION,

 

 IF(Action='Action1',SUM(SALES_CONVERTED)) as Sales_converted_Action1

ERROR:  Invalidad Expression

That IF function is located at the bottom.

 

 

Conversion_rates_mapping:
Mapping LOAD
 Action, 
 Conver_rate
 FROM [lib://TEST APP/Conversion_rates.xlsx]
(ooxml, embedded labels, table is CONVERSION_RATES);


[DATE_PRODUCTION]:
LOAD
    "Date",
    Action,
    Production,
    Production  *ApplyMap('Conversion_rates_mapping', Action) as SALES_CONVERTED
 FROM [lib://TEST APP/Conversion_rates.xlsx]
(ooxml, embedded labels, table is DATE_PRODUCTION);


[DATE_PRODUCTION_3]:
NoConcatenate
LOAD 
    "Date",
    IF(Action='Action1',SUM(SALES_CONVERTED)) as Sales_converted_Action1
    Conversion_rates_mapping:
Mapping LOAD
 Action, 
 Conver_rate
 FROM [lib://TEST APP/Conversion_rates.xlsx]
(ooxml, embedded labels, table is CONVERSION_RATES);


[DATE_PRODUCTION]:
LOAD
    "Date",
    Action,
    Production,
    Production  *ApplyMap('Conversion_rates_mapping', Action) as SALES_CONVERTED
 FROM [lib://TEST APP/Conversion_rates.xlsx]
(ooxml, embedded labels, table is DATE_PRODUCTION);


[DATE_PRODUCTION_3]:
NoConcatenate
LOAD 
    "Date",
    IF(Action='Action1',SUM(SALES_CONVERTED)) as Sales_converted_Action1
   
Resident [DATE_PRODUCTION] 
group by "Date";

 

Labels (2)
1 Solution

Accepted Solutions
tresB
Champion III
Champion III

Two things I would like to highlight:

  1.  You have to use Group By with an aggregation function (here  you are using sum)
  2.  You might want to check if really want to use If(..Sum(  or Sum(If(.... To me Sum(if(... looks more valid here 

View solution in original post

1 Reply
tresB
Champion III
Champion III

Two things I would like to highlight:

  1.  You have to use Group By with an aggregation function (here  you are using sum)
  2.  You might want to check if really want to use If(..Sum(  or Sum(If(.... To me Sum(if(... looks more valid here