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

dollar sign expansion inside if statement not working

Hi,

When I use the below expression in a chart, it gives an error that allocated memory exceeded

if(GetSelectedCount(%SubDimension) > 0,

SUM(TOTAL <$(=%SubDimension)> Spend),

SUM(Spend)

)

However, the below expression works

if(GetSelectedCount(%SubDimension) > 0,

SUM(TOTAL Spend),

SUM(Spend)

)

This one alone also works

SUM(TOTAL <$(=%SubDimension)> Spend)

The only problem becomes when I use the dollar sign expansion inside the total and if it is inside an if statement

TOTAL <$(=%SubDimension)>

Any idea how to fix this?

15 Replies
MK_QSL
MVP
MVP

What is =%SubDimension?

Calculated Dimension?

Then it will not work... you can't use calculated dimension outside it's definition...

Provide sample data..

Not applicable
Author

As I said. It works already. It is just dynamically picking up the dimension based on the selection

The only problem is that it is not working inside the if statement. Otherwise, the expression alone works pretty well

Not applicable
Author

%SubDimension is coming from a field. It has the names of the dimension and when used with dollar sign, will point to the actual dimension

jyothish8807
Master II
Master II

Hi Syed,

Why are you putting $ sign over here ? What kind of field is "%SubDimension" ?

Try Like this:

if(GetSelectedCount(%SubDimension) > 0,  SUM(TOTAL <%SubDimension)> Spend),  SUM(Spend))

Regards

KC

Best Regards,
KC
Not applicable
Author

Because the %Subdimension field contains the names of the dimension. For example, Supplier, Product etc. When you use it with $ sign, it will refer to the actual dimension. For example, if you select Product from the list, it will as if a product dimension was used in the dimension field. Please read the dollar sign expansion first to understand my problem

MK_QSL
MVP
MVP

Try below one..


if(GetSelectedCount(%SubDimension) > 0, 

SUM(TOTAL <$(=Concat(DISTINCT %SubDimension,','))> Spend), 

SUM(Spend) 

)

MK_QSL
MVP
MVP

Try below one..


if(GetSelectedCount(%SubDimension) > 0,

SUM(TOTAL <$(=Concat(DISTINCT %SubDimension,','))> Spend),

SUM(Spend)

)

Not applicable
Author

nope..does not work

MK_QSL
MVP
MVP

Provide sample data... or sample app. Difficult to guess and answer..