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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
IamTDR
Responsive Resident
Responsive Resident

Unique Products Top 3 Sales Months

 

Hi

In Power BI, can you write a measure that could display a unique product's top 3 selling months over a time span?

Ideally I would like to show each product's top selling months. 

 

Example data 

ProductJanFebMarAprMayJunJulAugSepOctNovDec
A205214144534645229614187
B556015782033581264928247
C445518162036374364592554
D105416243540641791728237

 

 

So for example, Product A results should be Dec at 87, Jul at 64, and Oct at 61.

 

I could do this fairly easily in excel using conditional formatting top/bottom rules.  Trying to translate this to BI

 

THanks!

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

Hi IamTDR ,

 

To achieve your requirement, click Query Editor-> Transform-> Cilck on columns [Jan] ~ [Dec]-> Click "Unpivot Columns".

1.PNG 

After apply&closed, create a calculate column using DAX formula as below:

Rank = RANKX(FILTER(Table1, Table1[Product] = EARLIER(Table1[Product])), RANKX(ALL(Table1), Table1[Value]), , ASC, Dense)

2.PNG 

Finally, create a matrix chart and a slicer chart based on Rank column, set range 1~3 in the slicer chart, you will see what you expected.

3.PNG 

 

Regards,

Jimmy Tao

View solution in original post

3 REPLIES 3
v-yuta-msft
Community Support
Community Support

Hi IamTDR ,

 

To achieve your requirement, click Query Editor-> Transform-> Cilck on columns [Jan] ~ [Dec]-> Click "Unpivot Columns".

1.PNG 

After apply&closed, create a calculate column using DAX formula as below:

Rank = RANKX(FILTER(Table1, Table1[Product] = EARLIER(Table1[Product])), RANKX(ALL(Table1), Table1[Value]), , ASC, Dense)

2.PNG 

Finally, create a matrix chart and a slicer chart based on Rank column, set range 1~3 in the slicer chart, you will see what you expected.

3.PNG 

 

Regards,

Jimmy Tao

Anonymous
Not applicable

Hi @IamTDR

 

Pivot the data in Query Editor and then you can use the TOP N/ Bottom N filter in visual filter.

 

Thanks

Raj

IamTDR
Responsive Resident
Responsive Resident

Thanks for the quick reply.

 

This method would provide top sales overall though correct?  I am interested in keep each unique product and then being Power BI show me the top sales months over a few years of data.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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