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

Summarized table to show top 10 of each category

Hello,

 

I am trying to create a summarized table off raw data. This summarized table will show me the top "X" selling products (based on revenue) in each product family, for each region... I would also like to see the percent of the grand total each product makes for the product family and region. So logically, I need to find the sum of total revenue for each product family and Product Number in each Region. Then I need to compare the sum of the product number to the overall product family to determine the highest sold product.

Below is a sample data table of the columns and data I am working with. Let me know if you are able to help! thanks!!

 

gbuGBU custlobregionproduct_familyProduct NumberQuantitySum of monthly_revenue_usd_amount
IRSIRS1phAMERICASAA1325
IRSIRS1phAMERICASAA1230
IRSIRS1phAMERICASAA2550
IRSIRS1phAMERICASAA2675
IRSIRS1phAMERICASBB11060
IRSIRS1phAMERICASBB1940
IRSIRS1phAMERICASBB2890
IRSIRS1phAMERICASBB2415
IRSIRSRackAMERICASCC1620
IRSIRSRackAMERICASCC1240
IRSIRSRackAMERICASCC23250
IRSIRSRackAMERICASCC21160
IRSIRSRackAMERICASDD1220
IRSIRSRackAMERICASDD17400
IRSIRSRackAMERICASDD2810
IRSIRSRackAMERICASDD24250
IRSIRSRackAMERICASDD2670

 

Expected output for the top 2 products for each family in each region:

 

RegionProduct CategoryProduct FamilyProduct NumQtyRev% of LoB
Americas1PhAA21112532%
Americas1PhBB21210527%
AmericasRackCC2441034%
AmericasRackDD1942034%

 

I will have multiple regions, product categories and product families in the real data.

 

 

1 ACCEPTED SOLUTION

maybe try this

Table 2 = 
VAR tbl=ADDCOLUMNS( SUMMARIZE('Table','Table'[region],'Table'[lob],'Table'[product_family],'Table'[Product Number],"qty",sum('Table'[Quantity]),"rev",sum('Table'[Sum of monthly_revenue_usd_amount])),"%lob",[rev]/ CALCULATE(sum('Table'[Sum of monthly_revenue_usd_amount]),ALLEXCEPT('Table','Table'[lob] )))
var tbl2=ADDCOLUMNS(tbl,"rank",rankx(filter(tbl,[lob]=EARLIER([lob]) && [region]=earlier[region]),[rev],,DESC))
return filter(tbl2,[rank]<3)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
KellerB
Frequent Visitor

Hello Ryan,

 

Thanks for the note! I am trying to get the ranking for each lob for each Region. This seems to look at the lob globally.


So my real data will have Americas, Europe, and Asia. So i would like the top "X" revenue products for each lob for each region. Let me know if this makes sense or if I need to elaborate.

maybe try this

Table 2 = 
VAR tbl=ADDCOLUMNS( SUMMARIZE('Table','Table'[region],'Table'[lob],'Table'[product_family],'Table'[Product Number],"qty",sum('Table'[Quantity]),"rev",sum('Table'[Sum of monthly_revenue_usd_amount])),"%lob",[rev]/ CALCULATE(sum('Table'[Sum of monthly_revenue_usd_amount]),ALLEXCEPT('Table','Table'[lob] )))
var tbl2=ADDCOLUMNS(tbl,"rank",rankx(filter(tbl,[lob]=EARLIER([lob]) && [region]=earlier[region]),[rev],,DESC))
return filter(tbl2,[rank]<3)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ryan_mayu
Super User
Super User

@KellerB 

you can try this to create a new table

Table 2 = 
VAR tbl=ADDCOLUMNS( SUMMARIZE('Table','Table'[region],'Table'[lob],'Table'[product_family],'Table'[Product Number],"qty",sum('Table'[Quantity]),"rev",sum('Table'[Sum of monthly_revenue_usd_amount])),"%lob",[rev]/ CALCULATE(sum('Table'[Sum of monthly_revenue_usd_amount]),ALLEXCEPT('Table','Table'[lob] )))
var tbl2=ADDCOLUMNS(tbl,"rank",rankx(filter(tbl,[lob]=EARLIER([lob])),[rev],,DESC))
return filter(tbl2,[rank]<3)

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.