Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

behavior of MAX() Vs $(=Max()) in Expression

Hi,

When i used Max(DATE) it will return me the Max Date according to the dimension, but when i used =$(=MAX(DATE)). its return me all 16 value which is max over through the application.

How can i write a Variable in such way that it work same like MAX(DATE).

SESSIONID MAX(DATE) =16
16 16
1000001416
1000021616
1000031616
1000041616
1000061616
1 Solution

Accepted Solutions
tresesco
MVP
MVP

If you define a variable like :  Max(DATE)  //Note: no '=' symbol preceded

                                               it would work as expected. However, if you use that variable in set analysis, it would work differently, only 16 would be produced (because set anaysis evaluates once for an object and not dimension-wise). And yes,    =$(=MAX(DATE)) produces 16 beacuse, it gets evaluated outside the object where you use it. For better understanding, you might read the blog:  http://community.qlik.com/blogs/qlikviewdesignblog/2013/11/18/dollar-expansions.

View solution in original post

10 Replies
tresesco
MVP
MVP

If you define a variable like :  Max(DATE)  //Note: no '=' symbol preceded

                                               it would work as expected. However, if you use that variable in set analysis, it would work differently, only 16 would be produced (because set anaysis evaluates once for an object and not dimension-wise). And yes,    =$(=MAX(DATE)) produces 16 beacuse, it gets evaluated outside the object where you use it. For better understanding, you might read the blog:  http://community.qlik.com/blogs/qlikviewdesignblog/2013/11/18/dollar-expansions.

rubenmarin

Hi Jitendra, variables are expanded before creating the table, in example, imagine you have a variable vMaxDate and a expression $(vMaxDate)

If variable value is: =Max(Date), expression is expanded from '$(vMaxDate)' to '16'

If variable value is: Max(Date) (without the equal sign), expression is expanded from '$(vMaxDate)' to 'Max(Date)'

Not applicable
Author

Yes, i have checked that same.

I think same can possible in set analysis without making a variable.

tresesco
MVP
MVP

I guess set analysis would not help you here. Use FirstSortedValue() with Distinct. Check my reply on your other thread here: http://community.qlik.com/thread/156497

Not applicable
Author

Now i understand that i think MAX(DATE) in set Analysis will work same as its work in Expression. But it was not. So the other way is to make a variable of that and use that varaiable.

But why the Functions in Set Analysis not work same as they work in Expression... ?

rubenmarin

Hi, when you using $-expansion like you're doing in =$(=MAX(DATE)), it's calculated to create the expression, so it does first =Max(Date), resolve it as '16', so your expression is calculated as =16.

Once all dimensions and expressions are expanded, the table is calculated.

Set analysis is the same, it's applied when creating the expression, applying the selections of set analysis and creating a subset, using that subset the whole table is calculated.

So none of those, $-expansion and set analysis is are affected by row values, they are applied to create the table.

Not applicable
Author

That's why i was asking how can i use MAX(DATE) function in set Analysis so that it can work same as Its work in Expression fields. As what i know that is we have to use $(=<Exp>) when we want to use any functions etc.

rubenmarin

Hi Jitendra, it can't be done with set analisys. Because of that in your other post we proposed workarounds using functions like FirstSortedValue() or Aggr()

Not applicable
Author

Hi Ruben,

I understand that. but i was just thinking why this type of limitation is there in Set Analysis that's it.

I have already use the given suggestion.