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: 
SK28
Creator
Creator

CASE STATEMENT IN SQL TO QLIKVIEW

Hi,

Can anyone help me to write this statement in Qlikview

Sample Data:

WEEK         COUNT

1                   75000

2                    39000

3                     4000

4                       2600

5                         1400

6                          900

7                          300

8                           68

9                             2

10                           1

11                          100

12                           5

SO I NEED TO CREATE A BUCKET...!

REQUIRED OUTPUT

WEEK     COUNT

1              75000

2               39000

3-12         9376   (which is sum of all the other weeks except 1,2)

SQL CODE: TO GET THE ABOVE SAID OUTPUT

CASE

      WHEN WEEK IN (1,2) THEN

COUNT(WEEK) /WEEK

  ELSE SUM(WEEK)  END AS COULMN_NAME

IS THERE A WAY TO RESOLVE THIS ISSUE...??

THANKS IN ADVANCE..

5 Replies
sunny_talwar

Dimension

LOAD Week,

     Count,

     If(WEEK > 3, Dual('3-12', 3), WEEK) as Bucket

FROM ....

and not use Bucket as dimension and Sum(Count) as Expression

Not applicable

Dimension ->week

Expression->if(WEEK=1 ,Sum (COUNT),if(WEEK=2 ,Sum (COUNT),Sum({<WEEK-={1,2}>}total COUNT)))

Capture1.PNG

SK28
Creator
Creator
Author

Thank You

shiveshsingh
Master
Master

WEEK -={1,2}

Can u try by making above expression variable?

tyagishaila
Specialist
Specialist

If(WEEK > 3, Dual('3-12', 3), WEEK) as Bucket

What is the use of Dual over here?