Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
RaquelFQSpain
Contributor II
Contributor II

Chart with Agrr

I like to make a chart like this.

RaquelFQSpain_1-1616265750391.png

I use ID as Dimention and Measure, and the function:

=Aggr (If([COCHE={Coche}], Count[ID]/Count(total ID)), If([MOTO={Moto}], Count[ID]/Count(total ID)), If([VIDA={Vida}], Count[ID]/Count(total ID)), If([HOGAR={Hogar}], Count[ID]/Count(total ID)), If([<SALUD={Salud}>]), Count[ID]/Count(total ID)), If([ACCIDENTES={Accidentes}], Count[ID]/Count(total ID)), If([MOTO={Moto}]), Count[ID]/Count(total ID)), (Numeric, Descending))

The error I received is this:

RaquelFQSpain_2-1616266319581.png

May be I have to make a New dimention with fields: COCHE, MOTO, VIDA, HOGAR, SALUD, ACCIDENTES y MOTO. Pero no sé como hacerlo.

 

Labels (1)
2 Replies
rbartley
Specialist II
Specialist II

Hi,

It would  make more sense to transform your data in the data load editor so that you have fields:

ID, PROVINCIA, TIPO DE SEGURO, CANTIDAD.

Here's how I did it using the CrossTable() function:-

 

[data_temp]:
Load * Inline [
ID		PROVINCIA		COCHE		MOTO		HOGAR		SALUD		DENTAL		VIDA		ACCIDENTES
2	,	Barcelona	,	Coche	,		,	Hogar	,		,		,		,	
3	,	Zaragoza	,		,		,	Hogar	,		,		,		,	
5	,	Madrid	,	Coche	,	Moto	,		,	Salud	,		,		,	
15	,	Sevilla	,	Coche	,		,	Hogar	,	Salud	,		,		,	Accidentes
16	,	Madrid	,		,		,	Hogar	,		,	Dental	,		,	
26	,	A Coruña	,	Coche	,		,	Hogar	,		,		,		,	
39	,	Las Palmas	,	Coche	,		,		,		,		,		,	
40	,	Madrid	,	Coche	,	Moto	,	Hogar	,	Salud	,		,		,	
60	,	Barcelona	,		,		,	Hogar	,		,		,		,	
62	,	Madrid	,	Coche	,		,		,		,		,		,	
68	,	Madrid	,	Coche	,		,	Hogar	,		,		,	Vida	,	
89	,	Madrid	,	Coche	,		,	Hogar	,		,		,	Vida	,	
104	,	Madrid	,		,		,	Hogar	,		,		,		,	
117	,	Valencia	,	Coche	,		,	Hogar	,		,	Dental	,		,	Accidentes

];

[unpivot]:
CrossTable ("Tipo de Seguro",Cantidad_Tmp,2)
Load 
*
Resident [data_temp];

Drop table [data_temp];

Join
Load 
ID,
PROVINCIA,
"Tipo de Seguro",
if(len(Cantidad_Tmp)>0,1,0) as "Cantidad"
Resident [unpivot];

 

Seguro.GIFSeguro2.GIF

 

 

qvd attached.

RaquelFQSpain
Contributor II
Contributor II
Author

Thank you very much. I´ll try to make it in the data load editor.