Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Hope_AA
Contributor III
Contributor III

setting a variable with set analysis in back end code

I'm trying to add the function below as a variable to my code instead of master measure but it keeps giving me errors. I tried breaking it up and using the variables but it's still not working. Can anyone help me?

sum(aggr(count({<Rprtd_Flag={'Y'}>} Distinct UniqueKey),[Service Date]))

 

thanks a lot..

 

1 Solution

Accepted Solutions
squeakie_pig
Creator II
Creator II

It's probably not liking the single quotes in your set analysis {'Y'}.  You need to break it up and use chr(39) instead.

= 'sum(aggr(count({<Rprtd_Flag={' &chr(39) &'Y' &chr(39) &'}>} Distinct UniqueKey),[Service Date]))'

 

View solution in original post

7 Replies
Gui_Approbato
Creator III
Creator III

I think you're missing some parenthesis or so ( assuming that Y is your variable)..

Try : 

sum(aggr(count({<Rprtd_Flag={'$(Y)'}>} Distinct UniqueKey),[Service Date]))

or

sum(aggr(count({<Rprtd_Flag={'$(=Y)'}>} Distinct UniqueKey),[Service Date]))

sunny_talwar

What error do you get?

Hope_AA
Contributor III
Contributor III
Author

Unexpected Token....

 
 
 

see below

sunny_talwar

Oh, you are trying to store this expression into a variable within the script? May be try SET like this

SET Cnt_All_Unique = Sum(Aggr(Count({<Rprtd_Flag = {'Y'}>} DISTINCT UniqueKey), [Service Date]));
Hope_AA
Contributor III
Contributor III
Author

sorry maybe I didn't explain well but yes, that's the whole code for this part which is still creating the same error.

SET Cnt_All_Unique = Sum(Aggr(Count({<Rprtd_Flag = {'Y'}>} DISTINCT UniqueKey), [Service Date]));
let Cnt_All_Unique= $(Cnt_All_Unique);

squeakie_pig
Creator II
Creator II

It's probably not liking the single quotes in your set analysis {'Y'}.  You need to break it up and use chr(39) instead.

= 'sum(aggr(count({<Rprtd_Flag={' &chr(39) &'Y' &chr(39) &'}>} Distinct UniqueKey),[Service Date]))'

 

Hope_AA
Contributor III
Contributor III
Author

That was it... thank you so much.

Really appreciate all your help both of you.