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 :
Vous trouverez la base de données en pièce-jointe.
@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 ) ) ) );
Here is how I created this chart
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
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 ) ) ) );
@mmarchandFSLR your code produces a graph that is totally different from mine.
My Chart
and the data table with the Rank column showing the rankings based upon Pourcentage
Your chart run on the same data but very different results
I believe the issue is that your rankings are ranking in ascending order.