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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Sai_Mohan
Contributor III
Contributor III

Using Pick () function

Hi all,

How to write pick statement for calculated values?

For Example: 

IF($(vtoggle)=1, YEAR($(=$(Date))),
IF($(vtoggle)=2, YEAR($(=$(Date))) & ' - Q' & ROUND((MONTH($(=$(Date)))+1)/3),
IF($(vtoggle)=3, TEXT(DATE($(=$(Date)),'YYYY - MM (MMM)')),
IF($(vtoggle)=4, YEAR($(=$(Date))) & ' -W' & WEEK(DATE($(=$(Date))))
)))) 

Here, vtoggle is var and date is the field . Iam calculating year, date, month and week.

i wrote this :

$( = pick(vtoggle, YEAR($(=$(Date))), YEAR($(=$(Date))) & ' - Q' & ROUND((MONTH($(=$(Date)))+1)/3),
TEXT(DATE($(=$(Date)),'YYYY - MM (MMM)')), YEAR($(=$(Date))) & ' -W' & WEEK(DATE($(=$(Date)))))
)
)

But iam getting some error in this expression. ERROR: "Chart is not visible due to undefined values".

Labels (2)
1 Solution

Accepted Solutions
asinha1991
Creator III
Creator III

why not simply this way?

pick($(vtoggle),YEAR($(=$(Date))),YEAR($(=$(Date))) & ' - Q' & ROUND((MONTH($(=$(Date)))+1)/3),TEXT(DATE($(=$(Date)),'YYYY - MM (MMM)')))

View solution in original post

6 Replies
asinha1991
Creator III
Creator III

why not simply this way?

pick($(vtoggle),YEAR($(=$(Date))),YEAR($(=$(Date))) & ' - Q' & ROUND((MONTH($(=$(Date)))+1)/3),TEXT(DATE($(=$(Date)),'YYYY - MM (MMM)')))

sunny_talwar

If statement is working and all you are trying to do is to convert it into a Pick statement?

Sai_Mohan
Contributor III
Contributor III
Author

If statement is working, but iam getting performance issue . If i click buttons, it is taking long time to load

so i wanted to try with pick statement.

 

Sai_Mohan
Contributor III
Contributor III
Author

Thanks for the reply @asinha1991 .

If i use statement as you said, Inside year , month, week , quarter calculation which i have done is not working.

it is taking everything inside ' year', 'week' as year and week.

for example:

Pick ($(toggle), 'year', 'week')

i need output as 2015 and w2, instead its showing like year and week in words

sunny_talwar

Would you be able to share a sample showing what you have to help you better

Sai_Mohan
Contributor III
Contributor III
Author

Thank you @sunny_talwar @asinha1991 

I got the solution.

This the solution :    pick($(vtoggle),
                                                            YEAR($(=$(vdate))),
                                                             YEAR($(=$(vdate))) & ' - Q' & ROUND((MONTH($(=$(vdate)))+1)/3),
                                                             TEXT(DATE($(=$(vdate)),'YYYY - MM (MMM)')),
                                                             YEAR($(=$(vdate))) & ' -W' & WEEK(DATE($(=$(vdate))))
                                                                     )