Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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;
And this is what I want to achieve in the end;
Looking forward to the solutions!!!!!
Solved! Go to Solution.
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])
pls see the attachment below
Proud to be a Super User!
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:
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.
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:
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.
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])
pls see the attachment below
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.
Proud to be a Super User!
User | Count |
---|---|
78 | |
74 | |
41 | |
31 | |
28 |
User | Count |
---|---|
100 | |
93 | |
52 | |
50 | |
48 |