Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Just exploring.. Set expressions and code maintenance & re-usability aspect..
Is there any other/better way to maintain and reuse set expressions.. ?
Below is sample example I have created to demonstrate the current setup..
//Base Sales expression
vSales = Sum( { <Active = {1}, $1, $2 >} Sales)
//Product P1 Sales
vSalesP1 = vSales(Product = {'P1'})
//Region R1 Sales
vSalesR1 = vSales(Region = {'R1'})
//Region R1 Sales and Department D1
vSalesD1R1= vSales( Region = {'R1'}, Department= {'D1'} )
To use a variable like vSales could be quite useful but creating a whole bunch of them like in your example for (nearly) each combination of products/region/department/whatever is the opposite - what would be the benefit against writing the expressions directly? Beside this your approach based of the nesting of variables - in general it's possible but often it creates more complexity as it solved - therefore I don't recommend it (at least not as a general way to apply expressions).
- Marcus
One way is to assign the set expression in a variable and then use $-sign expansion.
For example
Sum( {< $(xSetRegion) , $(xSetDepartment) >} Sales)
where variable xSetRegion is assigned value Region = {"R1"}, and xSetDepartment is assigned value Department = {"D1"}
You can reuse the variable in other expressions.
To use a variable like vSales could be quite useful but creating a whole bunch of them like in your example for (nearly) each combination of products/region/department/whatever is the opposite - what would be the benefit against writing the expressions directly? Beside this your approach based of the nesting of variables - in general it's possible but often it creates more complexity as it solved - therefore I don't recommend it (at least not as a general way to apply expressions).
- Marcus