Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Jthurston
Contributor
Contributor

Help Streamline and Expression

Hi all!

Fairly new to Qlik and managed to write quite a complex expression that works and returns the results I need however I am sure that there must be a way of maybe streamlining this expression or making it more efficient.

Please let me know if you have any suggestions on what can be done or feel free to amend accordingly. I have attached the Expression - I copied it into a word doc.

Thanks!

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

There probably is, but for a more detailed response you will need to create a small sample qvw or qvf file with some representative data so that modifications can be tested.

Some tips:

This component

 

SUM({<
		[Metric]={"Income"},
		[Year]  ={'$(=$(v_CurrentYear))'},
		[Month]	={"Jan"}
	>}[Actual]) +
SUM({<
		[Metric]={"Income"},
		[Year] = {'$(=$(v_CurrentYear))'},
		[Month]	={"Jan"}
	>}[Outlook])

 

Could be replaced with 

 

SUM({<
	Metric = {'Income'},
	Year = {$(v_CurrentYear)},
	Month] = {'Jan'}
>} RangeSum(Actual, Outlook))

 

There are other places where you could do the same (same set expression). RangeSum() handles nulls and missing values correctly.

Use single quotes in set expressions for literals.  Use double quotes for search expressions. Use no quotes for simple numbers (like year). These may not matter on older versions of Qlik, but they do matter moving forward.

Avoiding unnecessary decoration (like fields in square brackets) makes expressions easier to read and maintain.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

1 Reply
jonathandienst
Partner - Champion III
Partner - Champion III

There probably is, but for a more detailed response you will need to create a small sample qvw or qvf file with some representative data so that modifications can be tested.

Some tips:

This component

 

SUM({<
		[Metric]={"Income"},
		[Year]  ={'$(=$(v_CurrentYear))'},
		[Month]	={"Jan"}
	>}[Actual]) +
SUM({<
		[Metric]={"Income"},
		[Year] = {'$(=$(v_CurrentYear))'},
		[Month]	={"Jan"}
	>}[Outlook])

 

Could be replaced with 

 

SUM({<
	Metric = {'Income'},
	Year = {$(v_CurrentYear)},
	Month] = {'Jan'}
>} RangeSum(Actual, Outlook))

 

There are other places where you could do the same (same set expression). RangeSum() handles nulls and missing values correctly.

Use single quotes in set expressions for literals.  Use double quotes for search expressions. Use no quotes for simple numbers (like year). These may not matter on older versions of Qlik, but they do matter moving forward.

Avoiding unnecessary decoration (like fields in square brackets) makes expressions easier to read and maintain.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein