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! Request now

Reply
Anonymous
Not applicable

DAX to return Highest and Lowest number in a column

Hi team,

 

I have a table something like this:

Table Name: Projects

 

Project NameRating
P10
P23
P3-2
P4-2
P2-3
P52
P32
P11
P2-1
P41
P51
P1-1
P1-3
P12
P1-2
P13

 

I want to query it to get the (i) Highest positive ratingfor each project and (ii) lowest negative rating for each project

 

Eg: For Project P1, it should be 3 and-3

 

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Try this.

max = 
var maxrate = CALCULATE(MAX('Table'[Rating]),ALLEXCEPT('Table','Table'[Project Name]))
return
IF(maxrate>0,maxrate,0)

min = 
var minrate = CALCULATE(MIN('Table'[Rating]),ALLEXCEPT('Table','Table'[Project Name]))
return
IF(minrate<0,minrate,0)

1.PNG

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

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

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous ,

 

Try this.

max = 
var maxrate = CALCULATE(MAX('Table'[Rating]),ALLEXCEPT('Table','Table'[Project Name]))
return
IF(maxrate>0,maxrate,0)

min = 
var minrate = CALCULATE(MIN('Table'[Rating]),ALLEXCEPT('Table','Table'[Project Name]))
return
IF(minrate<0,minrate,0)

1.PNG

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

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

mahoneypat
Microsoft Employee
Microsoft Employee

Please try this expression

 

Highest Positive =
CALCULATE ( MAX ( Project[Rating] ), Projects[Rating] > 0 )

 

Lowest Negative =
CALCULATE ( MIN ( Project[Rating] ), Projects[Rating] < 0 )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


lbendlin
Super User
Super User

Highest = 
var p=SELECTEDVALUE(Projects[Project Name])
return calculate(max(Projects[Rating]),filter(all(Projects),Projects[Project Name]=p))

Lowest = 
var p=SELECTEDVALUE(Projects[Project Name])
return calculate(min(Projects[Rating]),filter(all(Projects),Projects[Project Name]=p))

 

You may need to replace ALL() with a context modifier that suits your scenario.

edhans
Super User
Super User

MIN and MAX will do.

 

MIN(Table[Field])

MAX(Table[Field])

2020-06-16 18_12_55-Untitled - Power BI Desktop.png

 

If you are trying to show the MIN/MAX without being impacted by the Project Name, use this:

 

Measure =
MAXX(
    ALL(TableName),
    TableName[FieldName]
)

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Thanks for your answer.
I understand we have MIN and MAX, but that will not take the positive and negative into consideration.
Eg: if I have Ratings as -1 and -2 for a project, and if I query for highest Positive rating, it will return -1 but actually there are no positive ratings

so what do you want to return in such a case? Zero or nothing?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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