Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
nihhalmca
Specialist II
Specialist II

Set Analysis

Hi All,

sum( {$<Year = {$(#=Only(Year)-1)}>} Sales )

In above example can you say how works '#' and 'Only'.

Thanks you

Regards,

Nihhal.

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi Nihhal,

# is optional, so forget about it.

Only()  - Returns a possible or selected value of a field, there should be only one value possible/selected otherwise it will return null.

Suppose if you select Year 2014 and 2013 Only(Year) will return null.

To overcome this Max(Year) is use.

=sum({<Year = {$(=Max(Year)-1)}>} Sales)


Regards,

Jagan.

View solution in original post

3 Replies
morgankejerhag
Partner - Creator III
Partner - Creator III

The # is just part of the dollar sign expansion for set analysis. That functionality allows you to calculate a value to use for assignment to Year.

The only() function returns the value of the field within only if a single value is selected. So selected two years will return null instead. You can switch this to for example max(). In this case you still see values even if you have multiple years selected.

its_anandrjs

Hi,

In the above expression Only(Year)-1 means current selection of year field less one year value selected and if only one value is selected means not 2014,2013. And # is nothing here or better you select the some of this expressions

You can use some of this expressions

sum( {$<Year = {$(=Only(Year)-1)}>} Sales )

Or

sum( {$<Year = {$(=Max(Year)-1)}>} Sales )

Regards

Anand

jagan
Luminary Alumni
Luminary Alumni

Hi Nihhal,

# is optional, so forget about it.

Only()  - Returns a possible or selected value of a field, there should be only one value possible/selected otherwise it will return null.

Suppose if you select Year 2014 and 2013 Only(Year) will return null.

To overcome this Max(Year) is use.

=sum({<Year = {$(=Max(Year)-1)}>} Sales)


Regards,

Jagan.