Forum Discussion
Top 5 Bar Chart Comparison
Hello People 😁
I am writing to you because of a doubt I have.
Is there a way to create a bar or line graph in which I show the top 5 and not be a product of a certain classification that takes the top 5 and replaces it with that particular product?
Thank you very much in advance for answering, and sorry if I wrote something very odvio or unclear.
Someone can help me 😭
3 Replies
- amitchandakSuper User
- AnonymousNot applicable
Hi Syndicate_Admin ,
If you want to replace it to a specific product, you need to replace it in Power Query.
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
(2) Click "Advanced Editor", paste the following code, and then click "Close and Apply". You can also refer to the steps on the right side of the following PBIX.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSsrMTlXSUUoEYiMDpVidaKWCjPw8kFASEBtDhMoTS5IzoEImEKGSMijfFKorNQ/ISQZiM4hAUWlOahFUyBwoFAsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t, #"type" = _t, sale = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"type", type text}, {"sale", Int64.Type}}), #"Sorted Rows" = Table.Sort(#"Changed Type",{{"sale", Order.Descending}}), #"Kept Range of Rows" = Table.Range(#"Sorted Rows",0,5), #"Replaced Value" = Table.ReplaceValue(#"Kept Range of Rows","ruler","new_top1",Replacer.ReplaceText,{"Product"}), #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","pen","new_top2",Replacer.ReplaceText,{"Product"}), #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","tv","new_top3",Replacer.ReplaceText,{"Product"}), #"Replaced Value3" = Table.ReplaceValue(#"Replaced Value2","watch","new_top4",Replacer.ReplaceText,{"Product"}), #"Replaced Value4" = Table.ReplaceValue(#"Replaced Value3","phone","new_top5",Replacer.ReplaceText,{"Product"}) in #"Replaced Value4"(3) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Syndicate_AdminAdministrator
Thanks for replying! 😄 I understand what you're saying, but doing that would replace the data in a flat table, right? 😞 Part of the problem is that I need it to be dynamic, that is.
I have a market with different participants, which includes several products of the company for which I work, the problem is that when I select with a filter a market segmentation I can visualize the product of the company next to the top 5 regardless of whether or not the product is in top 5. Attached is an example of the problem