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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis problem

Hi Friends

I have this problem in a line graph chart, the dimension is

Mes

The Expression is:

(Sum( {$<[Nombre Clasificacion Producto] = {'Platos Principales'},[Codigo Centro de Costo]={"=Sum({$<Año = {$(#=Only(Año)-1)},Mes={$(=$(vMesSeleccionado))}>}[Valor Bruto])"} 

>} [Cantidad Vendida] )

-

Sum({$<[Nombre Linea Producto] ={'Entradas'},[Codigo Centro de Costo]={"=Sum({$<Año = {$(#=Only(Año)-1)},Mes={$(=$(vMesSeleccionado))}>}[Valor Bruto])"},

       [Nombre Clasificacion Producto] = {'Platos Principales'} 

>}

If(Match([Nombre Unidad de Negocio],'Cadena Gourmet')>0,[Cantidad Vendida] ))

-

Sum({$<[Nombre Linea Producto] ={'Sopas'},[Codigo Centro de Costo]={"=Sum({$<Año = {$(#=Only(Año)-1)},Mes={$(=$(vMesSeleccionado))}>}[Valor Bruto])"},

       [Nombre Clasificacion Producto] = {'Platos Principales'} 

>}If(Match([Nombre Unidad de Negocio],'Cadena Gourmet')>0,[Cantidad Vendida] ))

-

Sum({$<[Nombre Linea Producto] ={'Complementos En Platos Principales'},[Codigo Centro de Costo]={"=Sum({$<Año = {$(#=Only(Año)-1)},Mes={$(=$(vMesSeleccionado))}>}[Valor Bruto])"},

       [Nombre Clasificacion Producto] = {'Platos Principales'} 

>}

If(Match([Nombre Unidad de Negocio],'Tradicional')>0,[Cantidad Vendida] ))

-

Sum({$<[Nombre Linea Producto] ={'Salsas Para Platos Pricipales'},[Codigo Centro de Costo]={"=Sum({$<Año = {$(#=Only(Año)-1)},Mes={$(=$(vMesSeleccionado))}>}[Valor Bruto])"},

       [Nombre Clasificacion Producto] = {'Platos Principales'} 

>}If(Match([Nombre Unidad de Negocio],'Tradicional')>0,[Cantidad Vendida] )))

/

Count({$<[Codigo Centro de Costo]={"=Sum({$<Año = {$(#=Only(Año)-1)},Mes={$(=$(vMesSeleccionado))}>}[Valor Bruto])"},[Nombre Centro de Costo]= {'*'}-{'Eventos*'},[Valor Bruto]={'*'}-{'0'}>}[Codigo Centro de Costo])

The problem is when i select more than one month, the result of expression is diferent.

Example if i select individual month the result is

Just Selected Ene - $6.783

Just Selected Feb - $5.423

Just Selected Mar - $6.151

If i selected Ene,Feb and Mar the values are:

Ene - $6.790

Feb - $5.446

Mar - $6.151

The problem are in this part of expression [Codigo Centro de Costo]={"=Sum({$<Año = {$(#=Only(Año)-1)},Mes={$(=$(vMesSeleccionado))}>}[Valor Bruto])"} that inclue all months in every month selected.

1 Solution

Accepted Solutions
Not applicable
Author

I made a field with a flag to indicate if the [Codigo Centro de Costo] has sales in the last year and i include this field in the  expresion

View solution in original post

6 Replies
danielrozental
Master II
Master II

Try to split your problem into smaller parts until you hit exactly what's causing you problems.

Not applicable
Author

The problem of expression are in this part [Codigo Centro de Costo]={"=Sum({$<Año = {$(#=Only(Año)-1)},Mes={$(=$(vMesSeleccionado))}>}[Valor Bruto])"} becose take a [Codigo Centro de Costo] in the all month of selection by the last year.

The aim of the formula is to calculate the [amount he sold] the current year but in the [cost center code] who had sold a year ago, the problem is that if the point had sales last year in any of the months selected, takes it as the sum of sale of the selection of two or more months is greater than zero.

It's clear the problem?

Example if i select individual month the result is

Just Selected Ene - $6.783

Just Selected Feb - $5.423

Just Selected Mar - $6.151

If i selected Ene,Feb and Mar the values are:

Ene - $6.790

Feb - $5.446

Mar - $6.151

rohit214
Creator III
Creator III

hey marcos can u send that document.

i m able to get proper.

thanks

rohit

rohit214
Creator III
Creator III

hi

marcos

plz try this

(Sum( {$<[Nombre Clasificacion Producto] = {'Platos Principales'},[Codigo Centro de Costo]={Sum({$"<Año = {$(#=Only(Año)-1)},Mes={$(=$(vMesSeleccionado))}>"}[Valor Bruto])}

>} [Cantidad Vendida] )

may  be it helps you

and let me know

thanks

rohit

Not applicable
Author

I tried but the expression show an error in  the first parentheses of this part Sum ( {$"<Año = {$(#=Only(Año)-1)},

Not applicable
Author

I made a field with a flag to indicate if the [Codigo Centro de Costo] has sales in the last year and i include this field in the  expresion