cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
hcarr01
Level VI

Graphique

Bonjour à tous,

 

Dans un graphique j'aimerais pouvoir afficher que les 3 premiers éléments selon un critère de pourcentage -> afficher que les 3 items avec le pourcentage le plus élevé par quarter :

hcarr01_0-1749131247294.png

 

Vous trouverez la base de données en pièce-jointe.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Graphique

@txnelson, I completely flaked on that and forgot that Col Rank chooses the lowest as number 1!  With a small edit, it works as it should.  Thanks for catching that.  Being hasty leads to mistakes.

 

Graph Builder(
	Transform Column(
		"Transform[POURCENTAGE]",
		Formula( Col Rank( 0 - :POURCENTAGE, :QUARTER ) )
	),
	Size( 731, 464 ),
	Show Control Panel( 0 ),
	Variables(
		X( :QUARTER ),
		X(
			:ITEM,
			Position( 1 ),
			Order By( :POURCENTAGE, Descending, Order Statistic( "Mean" ) )
		),
		Y( :POURCENTAGE ),
		Color( :ITEM )
	),
	Elements(
		Bar(
			X( 1 ),
			X( 2 ),
			Y,
			Legend( 14 ),
			Summary Statistic( "Sum" ),
			Label( "Label by Value" )
		)
	),
	Local Data Filter(
		Add Filter(
			columns( :"Transform[POURCENTAGE]"n ),
			Where( :"Transform[POURCENTAGE]"n <= 3 )
		)
	)
);

mmarchandFSLR_0-1749135744797.png

 

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Graphique

Here is how I created this chart

txnelson_0-1749132623450.png

I sorted the data table by Quarter and descending Pourcentage.

I then created a new column called Rank and set the formula to:

Col Cumulative Sum( 1, :QUARTER )

Then it was a simple matter to create the chart as specified, and to add a Local Data Filter and select the filter to use only the rank values of 1-3

txnelson_1-1749132866097.png

 

 

 

Jim

Re: Graphique

Very similar to Jim's solution but with a temporary Transform Column:

 

Graph Builder(
	Transform Column(
		"Transform[POURCENTAGE]",
		Formula( Col Rank( :POURCENTAGE, :QUARTER ) )
	),
	Size( 731, 464 ),
	Show Control Panel( 0 ),
	Variables(
		X( :QUARTER ),
		X(
			:ITEM,
			Position( 1 ),
			Order By( :POURCENTAGE, Descending, Order Statistic( "Mean" ) )
		),
		Y( :POURCENTAGE ),
		Color( :ITEM )
	),
	Elements(
		Bar(
			X( 1 ),
			X( 2 ),
			Y,
			Legend( 14 ),
			Summary Statistic( "Sum" ),
			Label( "Label by Value" )
		)
	),
	Local Data Filter(
		Add Filter(
			columns( :"Transform[POURCENTAGE]"n ),
			Where( :"Transform[POURCENTAGE]"n <= 3 )
		)
	)
);
txnelson
Super User

Re: Graphique

@mmarchandFSLR your code produces a graph that is totally different from mine.

My Chart

txnelson_0-1749134894459.png

and the data table with the Rank column showing the rankings based upon Pourcentage

txnelson_1-1749135102881.png

Your chart run on the same data but very different results

txnelson_2-1749135176878.png

I believe the issue is that your rankings are ranking in ascending order.

 

 

Jim

Re: Graphique

@txnelson, I completely flaked on that and forgot that Col Rank chooses the lowest as number 1!  With a small edit, it works as it should.  Thanks for catching that.  Being hasty leads to mistakes.

 

Graph Builder(
	Transform Column(
		"Transform[POURCENTAGE]",
		Formula( Col Rank( 0 - :POURCENTAGE, :QUARTER ) )
	),
	Size( 731, 464 ),
	Show Control Panel( 0 ),
	Variables(
		X( :QUARTER ),
		X(
			:ITEM,
			Position( 1 ),
			Order By( :POURCENTAGE, Descending, Order Statistic( "Mean" ) )
		),
		Y( :POURCENTAGE ),
		Color( :ITEM )
	),
	Elements(
		Bar(
			X( 1 ),
			X( 2 ),
			Y,
			Legend( 14 ),
			Summary Statistic( "Sum" ),
			Label( "Label by Value" )
		)
	),
	Local Data Filter(
		Add Filter(
			columns( :"Transform[POURCENTAGE]"n ),
			Where( :"Transform[POURCENTAGE]"n <= 3 )
		)
	)
);

mmarchandFSLR_0-1749135744797.png

 

Recommended Articles