Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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.
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
Try it like:
=$(fTestFunction($(=Sum({$<USState={"SC"},Fruit={'Pineapple'}>}Dollars))))
Edit : corrected with '$'
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.
😥
Try this
=$(fTestFunction('Sum({$<USState={"SC"},Fruit={"Pineapple"}>}Dollars)'))
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.
Try this
=$(fTestFunction("Sum({$<USState={"SC"},Fruit={'Pineapple'}>}Dollars)"))
Or
=$(fTestFunction('Sum({$<USState={"SC"},Fruit={'Pineapple'}>}Dollars)'))
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