Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
paulwalker
Creator II
Creator II

Conditional Value

Hi Community,

I Have below table which is Category, Date and Sales.

CategoryDateSales
A3/16/2020200
B3/16/2019240
C1/12/2019120
D12/12/20189
E2/3/2020890
F3/12/2020345
G1/1/2020500

 

my scenario is - IF category is at least  one A,B and E for current year then 100 else 200

Output would be the 

CategoryDateSalesOutPut Column
A3/16/2020200100
B3/16/2019240200
C1/12/2019120200
D12/12/20189200
E2/3/2020890100
F3/12/2020345200
G1/1/2020500200

 

Thanks in Advance

Labels (1)
1 Solution

Accepted Solutions
tresesco
MVP
MVP

Try like:

Load
If(match(Category, 'A', 'B', 'E') and Year(Date)=Year(Today()), 100, 200) as NewCol,
*;
LOAD Category, 
Date#(Date,'M/D/YYYY') as Date, 
Sales
FROM
[https://community.qlik.com/t5/New-to-QlikView/Conditional-Value/td-p/1684818]
(html, utf8, UserAgent is 'Mozilla/5.0', embedded labels, table is @1);

View solution in original post

4 Replies
tresesco
MVP
MVP

Try like:

Load
If(match(Category, 'A', 'B', 'E') and Year(Date)=Year(Today()), 100, 200) as NewCol,
*;
LOAD Category, 
Date#(Date,'M/D/YYYY') as Date, 
Sales
FROM
[https://community.qlik.com/t5/New-to-QlikView/Conditional-Value/td-p/1684818]
(html, utf8, UserAgent is 'Mozilla/5.0', embedded labels, table is @1);
JosephMorales
Partner - Contributor II
Partner - Contributor II

Hi @paulwalker ,

You can try this in the script:

DATA_TEMP:
LOAD * INLINE [
Category, Date, Sales
A, 3/16/2020, 200
B, 3/16/2019, 240
C, 1/12/2019, 120
D, 12/12/2018, 9
E, 2/3/2020, 890
F, 3/12/2020, 345
G, 1/1/2020, 500
];

DATA:
LOAD *,
IF(MATCH(Category,'A','B','E') AND YEAR(Date)=YEAR(TODAY()),100,200) AS OutPut
Resident DATA_TEMP;

DROP TABLE DATA_TEMP;
CrawleyTrina
Contributor
Contributor


@JosephMorales wrote:

Hi @paulwalker ,

You can try this in the script: upsers

 

 

DATA_TEMP:
LOAD * INLINE [
Category, Date, Sales
A, 3/16/2020, 200
B, 3/16/2019, 240
C, 1/12/2019, 120
D, 12/12/2018, 9
E, 2/3/2020, 890
F, 3/12/2020, 345
G, 1/1/2020, 500
];

DATA:
LOAD *,
IF(MATCH(Category,'A','B','E') AND YEAR(Date)=YEAR(TODAY()),100,200) AS OutPut
Resident DATA_TEMP;

DROP TABLE DATA_TEMP;

 

 


I have try this.

Brett_Bleess
Former Employee
Former Employee

Paul, you have multiple posts, please be sure to properly close out your thread by using the Accept as Solution button on the one(s) that helped, as this provides credit for the poster and lets other members know which post(s) actually helped.  It is greatly appreciate if you return and close this one out, or leave an update with what you still need.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.