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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Max of sum calculated

Hi guys,

 

Could you help me to solve to solve this issue. I have spent more than one day on it and I still have't found any solution.

 

Within a commercial team, I need for each sales manager to have the product most sold compared to the total products sold.

 

Here is an example of the table

 

Capture.PNG

 

Result, for all the period should be:

 

Capture2.PNG

 

Obviously, I should be able to have this information for all the period selected...

 

If I choose, only March, the result should be:

 

Capture3.PNG

 

Thanks for your help !

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Create a measure like this and apply it to visual level filter.

Measure 2 =
VAR best_product_1 =
    FIRSTNONBLANK (
        TOPN ( 1, ALL ( 'Table'[Product] ), [qty of best product], DESC ),
        1
    )
RETURN
    IF ( MAX ( 'Table'[Product] ) = best_product_1, 1 )

V-lianl-msft_0-1604640869754.png

total sales = CALCULATE(SUM('Table'[Quantity]),ALL('Table'[Product]))
_% = DIVIDE([qty of best product],[total sales])

 

Sample .pbix

 

Best Regards,
Liang
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

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Try measure like

product Rank = RANKX(all(Table[product]),[Quantity])
TOP Quantity = sumx(filter(VALUES(Table[product]),[product Rank]=1),sum(Table[Quantity]))
TOP product = sumx(filter(VALUES(Table[product]),[product Rank]=1),max(Table([product]) ))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

Thanks for your quick answer.

 

I do not manage to appy your rankx formula: is there not any missing information within your formula (RANKX(all(Table[product]),[Quantity]) )?

 

Thanks for your help.

 

Hi @Anonymous ,

 

Create a measure like this and apply it to visual level filter.

Measure 2 =
VAR best_product_1 =
    FIRSTNONBLANK (
        TOPN ( 1, ALL ( 'Table'[Product] ), [qty of best product], DESC ),
        1
    )
RETURN
    IF ( MAX ( 'Table'[Product] ) = best_product_1, 1 )

V-lianl-msft_0-1604640869754.png

total sales = CALCULATE(SUM('Table'[Quantity]),ALL('Table'[Product]))
_% = DIVIDE([qty of best product],[total sales])

 

Sample .pbix

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors