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: 
Anonymous
Not applicable

Positive representation

Hello, I have this model where I have this "piramidal" chart made of bars, ones positive and the others negative. I want to make that value positive in the X axe of the char.

Besides, i have this =IF(IsNUll(getfieldselections (Mes)),Date(Date#(Max(Mes),'MM'),'MM'),num(month(date#(getfieldselections (Mes),'MMM'))) ) to get the max month if there is no selection at all. Now, I want to insert that into this set analysis =Count(DISTINCT{$<[TipoFecha]={'Periodo'}, [Sexo]={M}>}[Identificación afiliado]), is used to draw one side of the barchart.

Making a long story short, I want to use that conditional in the set analysis so when I don't have anything selected, the chart can show me the max month

Thanks

Selection.png

13 Replies
swuehl
MVP
MVP

Juan,

talking about the bar chart, you want to create something like a butterfly chart, right?

This is not an easy task in QV, but maybe this gives you some ideas:

community.qlik.com/message/145421

Stefan

deepakk
Partner - Specialist III
Partner - Specialist III

hi,

If you want to select by default Month, if there is no selection then you can try the below code.

Count(DISTINCT{$<[TipoFecha]={'Periodo'}, [Sexo]={M},Year={$(=Max(Year))},Month={$(=Max(Month))}>}[Identificación afiliado])

Deepak

Anonymous
Not applicable
Author

I wans't able to use that with my  model, I don't know if I'm missing something or what. Is there any explanation more clear?

Anonymous
Not applicable
Author

How should I use the Year={$(=Max(Year))}, Month={$(=Max(Month)), shoul I have them predefined?

deepakk
Partner - Specialist III
Partner - Specialist III

hi,

Yes you need to have the Year(Date) as Year and num(Month(Date)) as Month in your  a field in your Script

Deepak

Anonymous
Not applicable
Author

ok, I've done that, but all the bars in the chart disappear.

I just need to have the max value of the month and year when there is nothing selected. I was trying with this expressions:

=IF(IsNUll(getfieldselections (Mes)),Date(Date#(Max(Mes),'MM'),'MM'),num(month(date#(getfieldselections (Mes),'MMM'))) ) for month (the variable is called mesFiltro)

=IF(IsNull(getfieldselections (Año)),Max(Año),getfieldselections (Año)) for year (the variable is called añoFiltro)

and then using them as variables, and in the chart expression using them as this:

=Count(DISTINCT{$<TipoFecha={'Periodo'}, [Sexo]={M}, Mes=mesFiltro, Año=añoFiltro>}[Identificación afiliado]) for the right side of the chart

=-Count(DISTINCT{$<TipoFecha={'Periodo'}, [Sexo]={F}>}[Identificación afiliado]) for the left side of the chart

too difficult?

deepakk
Partner - Specialist III
Partner - Specialist III

hi,

Can you attach a sample file..

Deepak

Anonymous
Not applicable
Author

It's kind of big the file, mmm and I have tried some thing in the scripts but no answer

I attached it, finally.

deepakk
Partner - Specialist III
Partner - Specialist III

hi,

I got your problem.. you can create a single Yearmonth variable.

If you are creating a single yearmonth variable then u need to have a yearmonth field in the script as

Year(TempDate) & num(Month(TempDate),'00') as YearMonth

variable  will be as follows

vYearMonth = if(getselectedcount(Año) =0,Year(today())&num(month(today()),'00'),Max(YearMonth))

and use this variable in the expression

Count({$<YearMonth={$(vYearMonth)}>}[Identificación afiliado]))

I hope this solve your problem.

Deepak