Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
b_garside
Partner - Specialist
Partner - Specialist

String manipulation in action button ... need help

I have a button that toggles a string value that changes to this;

'Week of '&WeekName(GanttDate)  but drops the last part after 'Week of'

it wont work in my button. only if a Paste it directly in the variable editor.

Code for Action

=If(vTimeScaleGanttBtn = 1, 'MonthName(GanttDate)', 'Week of'&WeekName(GanttDate) )

1 Solution

Accepted Solutions
jerem1234
Specialist II
Specialist II

Yep, Jason is right.

However I think the & is missing and you need quotes around weekname:

=If(vTimeScaleGanttBtn = 1, 'MonthName(GanttDate)', chr(39) & 'Week of' & chr(39) & '&' & 'WeekName(GanttDate)' )

View solution in original post

9 Replies
jerem1234
Specialist II
Specialist II

Could you post a sample qvw that displays your problem?

My guess is that in your formula:

=If(vTimeScaleGanttBtn = 1, 'MonthName(GanttDate)', 'Week of'&WeekName(GanttDate) )

the 'Week of'&WeekName(GanttDate) is not a string, its a string with a function. Are you looking just for the string of it? or are you trying to accomplish something else?

Did you want 'Week of&WeekName(GanttDate)'?

Hope this helps!

b_garside
Partner - Specialist
Partner - Specialist
Author

Yes that seems close.. I was trying to concat a String to a Function. but in the action button I'm not sure how to code it syntax wise to make it work. I use a $ expansion in my chart where it plugs in.

2013-11-21_114719.png

This is what I get after I click the button. using this: 'Week of&WeekName(GanttDate)'

2013-11-21_114901.png

Jason_Michaelides
Luminary Alumni
Luminary Alumni

I think you need to replace the ' with Chr(39) so they resolve to ' when the $-expansion is used:

If(vTimeScaleGanttBtn = 1, 'MonthName(GanttDate)', Chr(39) & 'Week of ' & Chr(39) & WeekName(GanttDate) )


Hope this helps,


Jason

jerem1234
Specialist II
Specialist II

Yep, Jason is right.

However I think the & is missing and you need quotes around weekname:

=If(vTimeScaleGanttBtn = 1, 'MonthName(GanttDate)', chr(39) & 'Week of' & chr(39) & '&' & 'WeekName(GanttDate)' )

b_garside
Partner - Specialist
Partner - Specialist
Author

Yeah makes sense. Chr() works well.

Almost there. Maybe its missing a Chr(39). Tried adding oen on end then it just blew up.

Chr(39) & 'Week of ' & Chr(39) & WeekName(GanttDate)

2013-11-21_120108.png


Chr(39) & 'Week of ' & Chr(39) & WeekName(GanttDate)& Chr(39)

Did this;

2013-11-21_120321.png


b_garside
Partner - Specialist
Partner - Specialist
Author

That worked. Just need a to add a space. Wow tricky stuff.

Thanks All!

2013-11-21_120707.png

b_garside
Partner - Specialist
Partner - Specialist
Author

Jeremy real quick how would I convert this one to work?

Date(GanttDate,'DD')  The part that is getting me on this one is the 'DD')  part

jerem1234
Specialist II
Specialist II

This should do it:

='Date(GanttDate,' & chr(39) &'DD' & chr(39) & ')'

The trick is adding chr(39) anywhere you want to add the single quotes. It can be confusing sometimes i know haha

Hope this helps!

b_garside
Partner - Specialist
Partner - Specialist
Author

Awesome that worked.

I guess it takes some getting use to where to place these chr()