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.
Hi there,
I have a table with following fields:
Product Category
Product
Sale Date
Amount
I'm looking top 3 unique product sold for each product category and on which date.
Any help will be much appreciated.
Thanks,
P
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.
Solved! Go to Solution.
Firstly, create a new table using DAX below.
SummaryTable = SUMMARIZE('top 3 product sample data','top 3 product sample data'[Customer],'top 3 product sample data'[Product],"totalamount",SUM('top 3 product sample data'[ Amount ]))
Secondly, create a new column using DAX below in the new table.
Column = RANKX(FILTER('SummaryTable','SummaryTable'[Customer]=EARLIER('SummaryTable'[Customer])),'SummaryTable'[totalamount],,DESC,Dense)
Thirdly, create a Matrix as shown in the following screenshot, drag the new column to Visual level filters and set its value to be less than or equal to 3.
Regards,
Lydia
Firstly, create a new table using DAX below.
SummaryTable = SUMMARIZE('top 3 product sample data','top 3 product sample data'[Customer],'top 3 product sample data'[Product],"totalamount",SUM('top 3 product sample data'[ Amount ]))
Secondly, create a new column using DAX below in the new table.
Column = RANKX(FILTER('SummaryTable','SummaryTable'[Customer]=EARLIER('SummaryTable'[Customer])),'SummaryTable'[totalamount],,DESC,Dense)
Thirdly, create a Matrix as shown in the following screenshot, drag the new column to Visual level filters and set its value to be less than or equal to 3.
Regards,
Lydia
Going to try it in next hour or so and let you guys know how it goes? Stay tuned.
Thanks,
P
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.
One thing you missed in your proposed solution to include date, we don't want to see top 3 product across all time but instead top 3 product for specific date for a customer whereas your solution is giving top 3 product for each customer not considering date, I think two changes are required to achive that,
1st include date in summary
2nd modify rankx function
Thanks,
P
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.
Hey @v-yuezhe-msft
I extended your solution further, here is what I did, I highlighted the changes in BOLD
SummaryTable = SUMMARIZE(
'top 3 product sample data',
'top 3 product sample data'[Customer],
'top 3 product sample data'[Product],
'top 3 product sample data'[Date],
"totalamount",SUM('top 3 product sample data'[ Amount ])
)
Extended you rank column to add product to it, so now I get rank for each product for that customer.
Rank = RANKX(
FILTER(
'SummaryTable','SummaryTable'[Customer]=EARLIER('SummaryTable'[Customer]) &&
'SummaryTable'[Product]=EARLIER('SummaryTable'[Product])
),
'SummaryTable'[totalamount],,DESC,Dense
)
Added new column for Rank 2
Rank 2 = RANKX(
FILTER(
'SummaryTable','SummaryTable'[Customer]=EARLIER('SummaryTable'[Customer]) &&
'SummaryTable'[Column]=1)
),
'SummaryTable'[totalamount],,DESC,Dense
)
In filter I did
Rank = 1
Rank 2 Less Than Equal to 3
This gave me the result I'm looking for. Thanks for your help.
P
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.
Hi,
Show your data and the expected result.
here is link to sample data and also in csv remarks columns has what product/date/amount is 1st/2nd/3rd for each customer.
https://drive.google.com/file/d/0B4dPgH9_BPBrbG01OFg2cl83R0k/view?usp=sharing
Thanks,
P
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.
Hi,
Why would you want to return the result of 1,2,3 in a seperate column. I think you can get yoru desired result via a Pivot Table. Take a look at the screenshot
I didn't mean to return restult in seperate column, tht was my comment what is expected result.
Although I'm not planning to do it in PowerPivot but in PowerBI.
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
100 | |
80 | |
63 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |