Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
JustinDallas
Specialist III
Specialist III

Function Not Parsing Set-Analysis Expression

Hello Folks,

 

TL;DR How do I use a Set-Analysis expression that contains a comman in a function?

I have a function and I'm passing a Set Analysis expression to it.  It seems to break when it runs into the comma(,).  I have this test data below:

[Data Test]:
Load * Inline
[
	'Name', 'Dollars', 'USState', Fruit
    Dylan, 14, SC, Pineapple
    Taylor, 67, NC, Pineapple
    Jefferson, 86, NC, Cantaloupe
    Christian, 11, SC, Cantaloupe
    Joseph, 9, FL, Blackberry
]
;
Set fTestFunction = RangeMin($1,50)
;
Exit Script
;

 

And as a measure I have the following:

=$(fTestFunction(Sum({$<USState={"SC"},Fruit={'Pineapple'}>}Dollars)))

 

This ends up giving me the following statement.

Screenshot 2023-04-28 013911.png

 

As you can see, it's fine until it hits the comma and then it stops parsing.  How do I use a Set-Analysis expression that contains a comman in a function?

 

Any help is greatly appreciated.

Labels (2)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

This is a know problem. There is no syntax to directly include a comma as part of a variable-with-parameter argument.  A workaround is to use a proxy character and then Replace() in the expression. Like this:

 

 

fTestFunction = RangeMax($(=Replace($1,'|',',')), 50)

 

 

and then invoke it as:

 

 

=$(fTestFunction('Sum({$<USState={"SC"}|Fruit={''Pineapple''}>}Dollars)'))

 

 

If you want to define fTestFunction in the script, you will have to escape the "$(". There is a couple of ways, one is to use LET with &:

 

 

LET fTestFunction = 'RangeMax($' & '(=Replace($1,''|'','','')), 50)';

 

 

 

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

View solution in original post

6 Replies
tresesco
MVP
MVP

Try it like:

=$(fTestFunction($(=Sum({$<USState={"SC"},Fruit={'Pineapple'}>}Dollars)))) 

 

Edit : corrected with '$'

JustinDallas
Specialist III
Specialist III
Author

Hello @tresesco ,

It parses, but it seems like it evaluates it for the entire dataset, and not just dimensions it's associated with in the chart.

😥

Screenshot 2023-04-28 095056.png

Chanty4u
MVP
MVP

Try this 

=$(fTestFunction('Sum({$<USState={"SC"},Fruit={"Pineapple"}>}Dollars)'))

JustinDallas
Specialist III
Specialist III
Author

It still chokes on the comma.  I guess I'm more concerned about how the comma breaks the parsing.  I know quotes, single and double, along with dollar-signs can create issues, but I've never seen a comma cause something to act up outside of a CSV file.

 

Screenshot 2023-04-28 100918.png

Chanty4u
MVP
MVP

Try this 

=$(fTestFunction("Sum({$<USState={"SC"},Fruit={'Pineapple'}>}Dollars)"))

 

Or 

 

=$(fTestFunction('Sum({$<USState={"SC"},Fruit={'Pineapple'}>}Dollars)'))

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

This is a know problem. There is no syntax to directly include a comma as part of a variable-with-parameter argument.  A workaround is to use a proxy character and then Replace() in the expression. Like this:

 

 

fTestFunction = RangeMax($(=Replace($1,'|',',')), 50)

 

 

and then invoke it as:

 

 

=$(fTestFunction('Sum({$<USState={"SC"}|Fruit={''Pineapple''}>}Dollars)'))

 

 

If you want to define fTestFunction in the script, you will have to escape the "$(". There is a couple of ways, one is to use LET with &:

 

 

LET fTestFunction = 'RangeMax($' & '(=Replace($1,''|'','','')), 50)';

 

 

 

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com