Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Dynamically create the aggr expression

I want to generate my aggr expression dynamically depending on what the user selects

So aggr(sum(net_amount), contract_id)  will be the basic

In case they select dim1

It should be aggr(sum(net_amount), contract, dim1)

And if they choose dim1 and dim2

It should be aggr(sum(net_amount), contract, dim1, dim2)

Is this even possible ?

TIA

1 Solution

Accepted Solutions
stigchel
Partner - Master
Partner - Master

Well you can put any condition in the variable definition right? So, put in vDim something like

=if(GetSelectedCount(dim1)+GetSelectedCount(dim2)=0,'dim',

     if(GetSelectedCount(dim1)=1 and GetSelectedCount(dim2)=0,'dim,dim1',

          if(GetSelectedCount(dim2)=1,'dim,dim1, dim2'

)))

View solution in original post

3 Replies
stigchel
Partner - Master
Partner - Master

Yes construct a variable vDim where you have an expression like (with Dim being the field where you select Dim1 or Dim2)

='Contract,'&Concat(Dim,',')

And in your expression use

aggr(sum(net_amount),$(=vDim))

Not applicable
Author

Well, I want dim1 to appear only when they have selected something from Dim1 and as and when some value is chosen in Dim2 and Dim3 then the expression should be

aggr(sum(net_amount), dim) when nothing is chosen

aggr(sum(net_amount), dim,dim1) when a value in dim1 is chosen

aggr(sum(net_amount), dim,dim1, dim2) when a value in dim1 and dim 2 is chosen

stigchel
Partner - Master
Partner - Master

Well you can put any condition in the variable definition right? So, put in vDim something like

=if(GetSelectedCount(dim1)+GetSelectedCount(dim2)=0,'dim',

     if(GetSelectedCount(dim1)=1 and GetSelectedCount(dim2)=0,'dim,dim1',

          if(GetSelectedCount(dim2)=1,'dim,dim1, dim2'

)))