Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
phongnnguyen
Contributor II
Contributor II

Set analysis with variable

Dear guys,

I have a problem with my code to ignore current selection for variable

this is my code: {<BranchName=>}$(v_Interest) - with v_Interest is a variable

thanks for your help

Cheers,

4 Replies
sumit_ranjan_pa
Former Employee
Former Employee

Hi,

Set analysis is always used with calculated dimensions/facts. Your variable need to be encased in some kind of aggregation/calculation function, for it to work.

Similar to this: fact:

sum( {<BranchName=>}$(v_Interest) ) .

This would work fine.

Without the Sum/ count, it get bit tricky. However, if it is a dimension you can try this,

Aggr( Only({<BranchName=>} $(v_Interest) )

Let me know how it works out.

Thanks and regards,

Sumit

phongnnguyen
Contributor II
Contributor II
Author

Thanks for your reply, but this is not working with me.

Actually,

v_Interest =  if((interval(min(TradeDate)-CreateDate_Branch,'d'))>0,

sum({<BranchNameAE=>}if( k=0 and Interest>0,-Amount))/count(distinct TradeDate),

sum({<BranchNameAE=>}if( k=0 and Interest>0,-Amount))/NetWorkDays(CreateDate_Branch,max(TradeDate)))

sumit_ranjan_pa
Former Employee
Former Employee

Thank you for the code. Seems from the code, you can simplify it a bit.
You cannot use the set analysis without any aggregation functions. Using variable is fine but it needs to have a function outside.

Seems like you will have to add the values in every Set analysis inside the if condition.

If possible can you share the Application snippet and let us know what exactly you want of the script?

phongnnguyen
Contributor II
Contributor II
Author

Thanks for your information.

Actually, I wanna make the bar chart to show Interest of Branches. When I choose any Branch, I want it will show all Branches not just show currently selected.

v_Interest =  if((interval(min(TradeDate)-CreateDate_Branch,'d'))>0,

sum({<BranchNameAE=>}if( k=0 and Interest>0,-Amount))/count(distinct TradeDate),

sum({<BranchNameAE=>}if( k=0 and Interest>0,-Amount))/NetWorkDays(CreateDate_Branch,max(TradeDate)))