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
bo_afk
Post Patron
Post Patron

Performance of Top 10 over time

Hi,

 

In my data I have category name, sales, and week number. For each week, I would like to calculate the total sales for the top 10 categories and then see this trend over time. 

 

Does anyone know if this is possible?

 

Thanks

 

afk

 

1 ACCEPTED SOLUTION

Hi @bo_afk ,

 

To create measures as below.

 

sum = SUM(Table1[Sales])
Measure = var ran = RANKX(ALLEXCEPT(Table1,Table1[Week]),[sum],,DESC,Dense)
var k =FILTER(Table1,Table1[Rank]<=2)
return
CALCULATE([sum],KEEPFILTERS(k))

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @bo_afk ,

 

To create the measures as below.

a = SUM(Table1[sales])
k = 
VAR k =
    ADDCOLUMNS (
        Table1,
        "ranka", RANKX ( ALLEXCEPT ( Table1, Table1[week number] ), [a] )
    )
VAR kf =
    FILTER ( k, [ranka] <= 10 )
RETURN
    CALCULATE ( SUM ( Table1[sales] ), KEEPFILTERS ( kf ) )
Measure = 
CALCULATE (
    SUMX ( Table1, [k] ),
    FILTER ( ALL ( Table1 ), Table1[week number] <= MAX ( Table1[week number] ) )
)

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @v-frfei-msft , thanks for your response.

 

I tried your measures but it didn't seem to work for my data. Perhaps I didn't explain it properly.

See below a sample data set. For each week, in this example, I want to sum the sales for the top 2 categories. In Week 1 these are categories B and C with a total of 35 (20+15) and then in Week 2 these are categories A and C with a total of 31 (20+11)

Sample data    Desired Output
WeekCategorySalesRank Top 2 total
Week 1A103 Week 135
Week 1B152 Week 231
Week 1C201   
Week 2A201   
Week 2B73   
Week 2C112   

 

 

Hi @bo_afk ,

 

To create measures as below.

 

sum = SUM(Table1[Sales])
Measure = var ran = RANKX(ALLEXCEPT(Table1,Table1[Week]),[sum],,DESC,Dense)
var k =FILTER(Table1,Table1[Rank]<=2)
return
CALCULATE([sum],KEEPFILTERS(k))

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

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.