Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
fabiocovre
Advocate I
Advocate I

Find product with more sales

Hello,

 

I have the following database

 

Market Name --- Product --- Value

A --- apple --- 15

A --- pineapple --- 20

A --- apple --- 10

B --- apple --- 20

B --- watermelon --- 50

 

I'd like to return the table below

 

Market Name --- Product --- Total Sum

A --- Apple --- 45

B --- watermelon --- 70

 

Can anyone help me?

 

Thank you!

1 ACCEPTED SOLUTION

Got it, here is what you can do:

 

Add new measure to get total sales for each product within a market:

 

Product Sale = Calculate(sum(Fruit[Value]), AllExcept(fruit, Fruit[Market], Fruit[Product])) 

Now let's rank this sale, add new measure

 

Rank Product = RANKX(ALLEXCEPT(Fruit, Fruit[Market]), [Product Sale])

Add New table visual, drop market, product, product sale and rank product in it and in visual level filter choose where Rank Product = 1

 

Now 2nd question, get top product across all markets, add following measure:

 

Top Fruit Product = Calculate(MAX('Fruit'[Product]),  TOPN(1, Fruit, SUM(Fruit[Value]),DESC))

 

 

 Drop top fruit product on card visual and you will get "Watermelon"

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

8 REPLIES 8
pxg08680
Resolver III
Resolver III

@fabiocovre

a1.PNG

Going with your sample data, You need SUM of A and SUM of B whatever the product is. 

 

a1.PNGAdd a column as above and use table visual, Drop MarketName,Value,New column. 

a1.PNG

Drop down the value field and select SUM

 

 

Regards,

PXG08680

parry2k
Super User
Super User

use table visua and drop market name, product and value in values and next to value, in arrow, choose sum aggregation



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Sorry, I didn't understand...

 

That's what I thought: 

 

I created a new table with the markets name... and I thought to do a kind of lookup value of the max value to return the product with more sales:

 

 

Market Name --- Product

values(Marlet Name) --- lookupvalue (max(value))

A --- Apple

B --- Watermelon

 

 

share you data and expected result

 

I guess you want sum of market and what is your requirement to show product. is it which product has max value?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

The sum isn't the priority. My problem is to create a measure to discover wich product is sold more:

 

In the case, I'd like to see the result below

 

Visualization 1

Market Name --- Product

A --- Apple

B --- Watermelon

 

Visualization 2

Product

Watermelon

so definition of sold more is based on sum of values, correct?

 

and also you want it by market and overall as well, correcT?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

yes, that's it! sorry if I wasn't very clear in my explanation.

Got it, here is what you can do:

 

Add new measure to get total sales for each product within a market:

 

Product Sale = Calculate(sum(Fruit[Value]), AllExcept(fruit, Fruit[Market], Fruit[Product])) 

Now let's rank this sale, add new measure

 

Rank Product = RANKX(ALLEXCEPT(Fruit, Fruit[Market]), [Product Sale])

Add New table visual, drop market, product, product sale and rank product in it and in visual level filter choose where Rank Product = 1

 

Now 2nd question, get top product across all markets, add following measure:

 

Top Fruit Product = Calculate(MAX('Fruit'[Product]),  TOPN(1, Fruit, SUM(Fruit[Value]),DESC))

 

 

 Drop top fruit product on card visual and you will get "Watermelon"

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.