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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Variable not accept brackets.

Hello.

I have a variable that has the following syntax:

if($(VR_PZ_Médio_Entrega)<30,(sum(VENDAS_MES_ANTERIOR1)/(avg((Dias_Uteis_Anterior)))*(avg((Dias_Uteis_Atuais)) )*(1+$(VR_simulador_quant_venda))),

$(VR_PZ_Médio_Entrega)*((sum(VENDAS_MES_ANTERIOR1)/(avg((Dias_Uteis_Anterior)))*(avg((Dias_Uteis_Atuais)) )*(1+$(VR_simulador_quant_venda)))/30))

And her name is:

$(VR_Reposição_Quant_Venda_Prevista)

Now, if I put parenthesis between the variable, it does not bring value.

($(VR_Reposição_Quant_Venda_Prevista) )

--------------------------------------------------------------

Syntax brings the value of a field and divide by the number of working days in the previous month and multiply by the amount of days of current month.



Labels (1)
7 Replies
pover
Partner - Master
Partner - Master

What happens if you put the parentheses directly in the variable?

(

if($(VR_PZ_Médio_Entrega)<30,(sum(VENDAS_MES_ANTERIOR1)/(avg((Dias_Uteis_Anterior)))*(avg((Dias_Uteis_Atuais)) )*(1+$(VR_simulador_quant_venda))),

$(VR_PZ_Médio_Entrega)*((sum(VENDAS_MES_ANTERIOR1)/(avg((Dias_Uteis_Anterior)))*(avg((Dias_Uteis_Atuais)) )*(1+$(VR_simulador_quant_venda)))/30))

)

Regards.

Anonymous
Not applicable
Author

Do not bring any value ....

pover
Partner - Master
Partner - Master

If you are using this variable to divide something, make sure the second $(VR_PZ_Médio_Entrega) is not 0 because that seems to be the only part of the formula that would be affected by adding parentheses.

Regards.

Anonymous
Not applicable
Author

The variable (VR_PZ_Médio_Entrega) has value. Interesting is that if I leave the formula just = sum (VENDAS_MES_ANTERIOR1) it goes right to the same variable in parentheses. I took the formula the amount of previous days (avg ((Dias_Uteis_Anterior))) and current days avg ((Dias_Uteis_Atuais))). When I delete these two variables in the expression of my right. In variable (avg ((Dias_Uteis_Anterior))) the result is 22 and avg ((Dias_Uteis_Atuais))) is 23. If I replace my variable in the field by the expression, the result also of the right.

pover
Partner - Master
Partner - Master

Maybe QV doesn't like that you are nesting $($()). It might work if you put a = before the if() in the variable, but you might not get the result you want.

Regards.

Anonymous
Not applicable
Author

Further simplified my expression but still not bringing anything.
= sum (VENDAS_MES_ANTERIOR1) / avg ($ (Dias_Uteis_Anterior)).

If I make a variable with the expression above and take it to a field, does not work.

But if I take the full expression for the field she works.

I see it is a problem as that term is mounted in the variable.

Anonymous
Not applicable
Author

Another test I did was create another variable with the following expression: sum (VENDAS_MES_ANTERIOR1) / avg (NETWORKDAYS (MonthStart (AddMonths (today (),(- 1))), MonthsEnd (1, 1 )))). (),(- Today The variable name is: $ (VR_Reposição_Quant_Venda_Prevista). If within a column esso use the variable up that way, = $ (VR_Reposição_Quant_Venda_Prevista), she brings me the result. More to do as follows, = ($ (VR_Reposição_Quant_Venda_Prevista)) with the parenthesis it gives error. I'll need to have the relatives as the result of this variable with other fields will be used for other calculations. eg = ($ (VR_Reposição_Quant_Venda_Prevista) + A)-B / C.