Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am trying to use an if statement with a variable in my expression and I get no results. The variable works when I use the variable on it's own but when used with the if I get no results.
I have tried:
if(OrderQtr='Apr-Jun 2018',$(vAvgOrderCost),0)
if(OrderQtr='Apr-Jun 2018',sum($(vAvgOrderCost)),0)
sum($(vAvgOrderCost)if(OrderQtr='Apr-Jun 2018',0))
Nothing seems to work. Thanks
I see whats happening, you don't have a dimensión, so the if() always returns null() because each row has all quarternumbers, usually to add filters other than dimensions you need to use set analysis, wich will broke the use you are doing of variables, or you will need to pass the quarter as parameter
One quick fix can be adding an aggr to the expression, so each row will virtually check the quarters one by one:
Sum(Aggr(if(NumOrderQtr=43191,$(vAvgOrderCost),0), NumOrderQtr))
Hi,
what is the content of the variable ?
Hi, and also.."if(OrderQtr='Apr-Jun 2018',1,0)" returns '1' in the expected quarter?
The variable content is =Sum([Unit Cost PO])/Count([Unit Cost PO])
Also if(OrderQtr='Apr-Jun 2018',1,0)" did not return 1 in the expected quarter
Thanks
The variable content is =Sum([Unit Cost PO])/Count([Unit Cost PO])
Thanks
what is the column type of OrderQtr. that maybe the issue there
Money
Thanks
not sure why OrderQuarter is money but try converting it to string before doing the compare
try to remove the = sign on the variable and see if the expressions works
I'm sorry OrderQtr is not money. It is text. The result of the expression is money.