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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
tdrp
Frequent Visitor

Create filtered table based on max value

Hi, have been using Power BI for a while and I'm trying to get better in DAX

 

I have a problem that I'm trying to solve for months ( have a working solution in power query but the query update is very slow process )

 

So I am trying to create a calculated table where it returns the row that have the max value, with context filters by the columns "Data", "Emp"  ( this is relative) and "Numero"

 

So from this data sample I would want it to return the rows with red and orange text ( this will be applied to a bigger dataset with more months)

 

DataNumeroEmpTOTALSupervisor
01/12/2020400790P3040 
01/12/2020400790P3050Ana Antunes
01/12/2020400790P4435Filipe Almeida
01/12/2020400790P4440Filipe Leite
01/12/2020400790P3010Filipe Almeida

 

I've tried many approaches but none seems the "right" way of dealing with it

 

Would apprecciate all of your inputs on how you would deal with this problem

 

Thank you guys

1 ACCEPTED SOLUTION
HotChilli
Community Champion
Community Champion

I am a bit short of time to test this.

Can you use this and test it please?

TableX = VAR _tab = ADDCOLUMNS(TableY, "MaxTot", CALCULATE(MAX(TableY[TOTAL]), ALLEXCEPT(TableY, TableY[Emp], TableY[Data], TableY[Numero])))
RETURN
 FILTER(_tab, TableY[TOTAL] = [MaxTot])

View solution in original post

5 REPLIES 5
HotChilli
Community Champion
Community Champion

I am a bit short of time to test this.

Can you use this and test it please?

TableX = VAR _tab = ADDCOLUMNS(TableY, "MaxTot", CALCULATE(MAX(TableY[TOTAL]), ALLEXCEPT(TableY, TableY[Emp], TableY[Data], TableY[Numero])))
RETURN
 FILTER(_tab, TableY[TOTAL] = [MaxTot])
HotChilli
Community Champion
Community Champion

I'm still not seeing it.  The P44 rows have Total of 41 and 40 and the 40 row is in orange .

Silly of me, painted the wrong one when I pasted the data the second time, changed the value to make it right 😅

tdrp
Frequent Visitor

Hi @HotChilli , thank you for your response

 

Yes, the max value is from the total, forgot to mention that

 

The other row is returned beacause the column "Emp" has a different ID, it's another condition to filter by

 

Thank you 

HotChilli
Community Champion
Community Champion

"returns the row that have the max value"  Is this from the Total column?

 

Why is the orange line getting returned (

01/12/2020 400790 P44 40 Filipe Leite)

)

when the Total in the previous line is higher?

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors