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
Nouha
Frequent Visitor

Top n products every week

Hello ,

 

I have a dataset that looks like this

 

Week      Product         Sales

1                 A                   10

1                 B                    8 

1                 C                    9

1                 X                     2

...

2                 B                     1

2                 C                     50

2                 D                    6

...

3                A                     5

3                D                     3

3                 X                     1

3                B

3                 C

 

I want to be able to calculate a column that gives 1 if a product is in the top 10 sales of that week and 0 if its not in the top on that specific week

 

or any other creative way to indentify the Top 10 of every week in order to calculate an average of sales of the top 10 products of each week

 

Thank you a lot

 

Nouha 

1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @Nouha

 

You may refer to below measure which is the average of Top3 product sales' average value.

Measure 2 =
AVERAGEX (
    Table,
    CALCULATE (
        SUM ( Table[Sales] ),
        TOPN (
            3,
            ALLEXCEPT ( Table, Table[Week] ),
            CALCULATE ( SUM ( Table[Sales] ) ), DESC
        )
    )
        / 3
)

1.png

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-cherch-msft
Employee
Employee

Hi @Nouha

 

You may refer to below measure which is the average of Top3 product sales' average value.

Measure 2 =
AVERAGEX (
    Table,
    CALCULATE (
        SUM ( Table[Sales] ),
        TOPN (
            3,
            ALLEXCEPT ( Table, Table[Week] ),
            CALCULATE ( SUM ( Table[Sales] ) ), DESC
        )
    )
        / 3
)

1.png

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Sounds like you could use the TOPN function to create a new table. It is going to be a lot of work, but it could be done.

 

https://msdn.microsoft.com/en-us/query-bi/dax/topn-function-dax

Greg_Deckler
Super User
Super User

Sounds like you want a matrix visualization with Week and Product in the rows area and a measure based upon RANKX as a value.

 

https://msdn.microsoft.com/en-us/query-bi/dax/rankx-function-dax

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hello, 

 

unfortunatly I need to display as a card visualisation, i can do it in a table of a matrix but i need to calculate it and to be displayed in a card 

So, a variation on that RANKX measure and you have 2 slicers for week and product? Is that how you have this setup? 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.