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
0XMaijeh
Frequent Visitor

Getting the Max Value of Each Row Item (Summing the Duplicates too)

Hi Guys,

 

I have this problem where I want to return the max value for each row item, and where there are duplicates I want to sum them. 

 

This is a sample of the table I am working with; 

 

0XMaijeh_0-1665679899686.png

 

 

And this is what I want to achieve in the end;

 

0XMaijeh_1-1665679942993.png

 

Looking forward to the solutions!!!!!

2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@0XMaijeh 

maybe you can try this

Table = 
var tbl=SUMMARIZE('Table (2)','Table (2)'[bottle type],'Table (2)'[SHIPING CODE],'Table (2)'[WAREHOUSE],'Table (2)'[DISTRBUTOR],"value",sum('Table (2)'[STOCK VALUE]))
var tbl2=ADDCOLUMNS(tbl,"rank",rankx(FILTER( tbl,[bottle type]=EARLIER('Table (2)'[bottle type])),[value],,DESC))
var tbl3= FILTER(tbl2,[rank]=1)
return SELECTCOLUMNS(tbl3,"bottle type",[bottle type],"shipping code",[SHIPING CODE],"warehouse",[WAREHOUSE],"distributor",[DISTRBUTOR],"value",[value])

1.png

pls see the attachment below





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

Proud to be a Super User!




View solution in original post

v-yalanwu-msft
Community Support
Community Support

Hi, @0XMaijeh ;

You could create measures as follow:

Measure = 
CALCULATE(SUM('Table'[STOCK VALUE]),ALLEXCEPT('Table','Table'[bottle type],'Table'[SHIPING CODE]))
STOCK VALUE2 = 
VAR _MAX=
MAXX(SUMMARIZE(ALLEXCEPT('Table','Table'[bottle type]),[SHIPING CODE],"1",[Measure]),[1])
RETURN IF(_MAX=[Measure],_MAX)

The final show:

vyalanwumsft_0-1665727180331.png


Best Regards,
Community Support Team _ Yalan Wu
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

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi, @0XMaijeh ;

You could create measures as follow:

Measure = 
CALCULATE(SUM('Table'[STOCK VALUE]),ALLEXCEPT('Table','Table'[bottle type],'Table'[SHIPING CODE]))
STOCK VALUE2 = 
VAR _MAX=
MAXX(SUMMARIZE(ALLEXCEPT('Table','Table'[bottle type]),[SHIPING CODE],"1",[Measure]),[1])
RETURN IF(_MAX=[Measure],_MAX)

The final show:

vyalanwumsft_0-1665727180331.png


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

ryan_mayu
Super User
Super User

@0XMaijeh 

maybe you can try this

Table = 
var tbl=SUMMARIZE('Table (2)','Table (2)'[bottle type],'Table (2)'[SHIPING CODE],'Table (2)'[WAREHOUSE],'Table (2)'[DISTRBUTOR],"value",sum('Table (2)'[STOCK VALUE]))
var tbl2=ADDCOLUMNS(tbl,"rank",rankx(FILTER( tbl,[bottle type]=EARLIER('Table (2)'[bottle type])),[value],,DESC))
var tbl3= FILTER(tbl2,[rank]=1)
return SELECTCOLUMNS(tbl3,"bottle type",[bottle type],"shipping code",[SHIPING CODE],"warehouse",[WAREHOUSE],"distributor",[DISTRBUTOR],"value",[value])

1.png

pls see the attachment below





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

Proud to be a Super User!




Thank you so much! Your solution worked well for the context provided. However I just noticed that when I tried to filter by weeks, it does not change (I forgot to add weeks to the sample table I provided yikes!). Is there any way out of this?

if you want to apply filters, I think you need to create a measure, pls try @v-yalanwu-msft 's solution.





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

Proud to be a Super User!




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