Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
daveatkins
Partner - Creator III
Partner - Creator III

How to use variable in set expression

I want to calculate a count from the most recent week of data. I am able to accomplish this by hard coding the following expression:

count({$ <ReportingWeekStart={'4/24/2016'} >} Account)

I define a variable

vSelectionWeekStart = date(WeekStart(max(ReportingDate)))

and display the variable in a text box to make sure it is working...so it displays as "4/24/2016"

however, this expression below returns a count of the entire current selection, not just the most recent week:

count({$ <ReportingWeekStart={"=$(=vSelectionWeekStart)"} >} Account)

What is wrong?

1 Solution

Accepted Solutions
sunny_talwar

I guess what you need is to replace 4/24/2016 with an expression. To do that first step is to get the variable to expand to a correct number in a text box object. In your case, I am guessing that if you put $(vSelectionWeekStart) in a text box object you will see 04/24/2016. I just moved that within the dollar sign expansion -> $(=Whatever works in text box)

View solution in original post

4 Replies
settu_periasamy
Master III
Master III

Maybe try

count({$ <ReportingWeekStart={'$(vSelectionWeekStart)'} >} Account)

Or

count({$ <ReportingWeekStart={'$(=vSelectionWeekStart)'} >} Account)

sunny_talwar

Try this:

Count({$<ReportingWeekStart={'$(=vSelectionWeekStart)'}>} Account)

or

Count({$<ReportingWeekStart={'$(=$(vSelectionWeekStart))'}>} Account)

daveatkins
Partner - Creator III
Partner - Creator III
Author

it appears the second one works:

Count({$<ReportingWeekStart={'$(=$(vSelectionWeekStart))'}>}


the first does not. now, if only I understood why? I have a few others like this on the same report...will see how it goes.

sunny_talwar

I guess what you need is to replace 4/24/2016 with an expression. To do that first step is to get the variable to expand to a correct number in a text box object. In your case, I am guessing that if you put $(vSelectionWeekStart) in a text box object you will see 04/24/2016. I just moved that within the dollar sign expansion -> $(=Whatever works in text box)