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
andrearuggeri
Helper I
Helper I

Best and worst shop per week

Hi all,

I'm quite new to the whole Power BI thing and I'm trying to achieve all my reporting needs 🙂

I have a table with the daily sales coming from several shops (sorry for the long table)

What I would like to achieve is to have the best and worst selling shop in the last week (data gets updated every monday morning) and the amount of sales for that shop(s)

In the example the best shop in the last week would be ROMA (PORTA DI ROMA) with a total of 36 sales and the worst shop would be ARESE (MI) with 5 sales.

Thanks a lot!

 

DateShopSalesWeek
05/10/2020ROMA (PORTA DI ROMA)341
09/10/2020ROMA (PORTA DI ROMA)341
09/10/2020ORIO AL SERIO (BG)441
10/10/2020ROMA (PORTA DI ROMA)1341
10/10/2020ORIO AL SERIO (BG)1541
11/10/2020ORIO AL SERIO (BG)1141
11/10/2020ROMA (PORTA DI ROMA)1641
16/10/2020ORIO AL SERIO (BG)342
17/10/2020ORIO AL SERIO (BG)842
18/10/2020ORIO AL SERIO (BG)1242
16/10/2020ARESE (MI)2042
17/10/2020ARESE (MI)3142
23/10/2020ROMA (PORTA DI ROMA)1243
23/10/2020ORIO AL SERIO (BG)1443
23/10/2020ARESE (MI)543
24/10/2020ROMA (PORTA DI ROMA)1243
25/10/2020ROMA (PORTA DI ROMA)1243

 

2 REPLIES 2
amitchandak
Super User
Super User

@andrearuggeri , Try measures like

//assumes sales measure

Shop Rank desc  = RANKX(all(Table[Shop]),[Sales])

 

Shop Rank asc= RANKX(all(Table[Shop]),[Sales],,asc)

 

Rank top 1 bottom 1 = sumx(filter(VALUES(Table[Shop]),[Shop Rank desc ]=1 || [Shop Rank asc] =1 ),[Sales] )

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

Not sure I completely got it.

 

I did take a look to the RANKX thing but if I'm not wrong the solution you provided is not aggregating the sales per week, so the rank is per date...

 

I need to determine for each week which is the shop with the max total sales, then I need it to know for the latest week.

 

EDIT: I will edit the original post since I realize there's a missing part, sorry (

 

Thanks a lot

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.