Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Writing Case statements in Qlikview

Hi ,

How do i write Case statement in the Sql select statement in Qlikview.

I have to create a Column Minutes_of_Usage , and assign the values according to the Partitions_in_Use column.

The table jobx_veloce_utilization_snapshot has column Partitions_in_use columns,

I am getting syntax error for the belwo sql select statement,

UTIL_SNAPSHOT:
select *,
CASE when `qwebstats-veloce`.`jobx_veloce_utilization_snapshot`.'number_of_partitions' = '0' THEN 'Minutes_of_usage' ='0'
when `qwebstats-veloce`.`jobx_veloce_utilization_snapshot`.'number_of_partitions' = '1' then 'Minutes_of_usage' ='5'
when `qwebstats-veloce`.`jobx_veloce_utilization_snapshot`.'number_of_partitions' = '2' THEN 'Minutes_of_usage' ='10'
when `qwebstats-veloce`.`jobx_veloce_utilization_snapshot`.'number_of_partitions' = '3' then 'Minutes_of_usage' ='20'
when `qwebstats-veloce`.`jobx_veloce_utilization_snapshot`.'number_of_partitions' = '4' then 'Minutes_of_usage' ='20'
END


from `qwebstats-veloce`.`jobx_veloce_utilization_snapshot`;

Partitions In Use

Minutes of Usage

0

0

1

5

2

10

3

20

4

20



1 Reply
johnw
Champion III
Champion III

You write it exactly the same as you would write it in SQL, because you are writing SQL. However, you may need to write it like this, with the SQL keyword, to make sure QlikView knows it's SQL. Not certain about that, but that's the first thing I'd try.

LOAD *;
SQL SELECT
...