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

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

Reply
DeBIe
Post Partisan
Post Partisan

calculating min and max values with filter

Hello all,

 

I need to write something in DAX, but I can't figure out how to get the context right. Hopefully, you can help me.

 

I have a set of bills from different shops. I need to add a column that displays the minimum and maximum amount that has been paid to that supplier. Not from one specific bill, but from all bills together. Down below marked in thick black are the columns that I would like to add.

 

What the logic should do is: lookup all invoices from the supplier name in this row and find the min and max amount that has been paid. I have tried with CALCULATE(min(Table[Amount]),Table[Supplier]=Table[Supplier]

 

Bill NumberSupplierAmountMin Amount SupplierMax Amount Supplier
1Wallmart1010500
2Harry's505075
3Wallmart50010500
4Harry's755075
5Wallmart25010500
6Harry's605075
1 ACCEPTED SOLUTION

@DeBIe - Try:

Column =
  VAR __Supplier = [Supplier]
  VAR __District = [District]
  MINX(
    FILTER('Table',[Supplier]=__Supplier && [District]=__District),
    [Amount]
  )

Measure =
  VAR __Supplier = MAX([Supplier])
  VAR __District = MAX([District])
  MINX(
    FILTER(ALL('Table'),[Supplier]=__Supplier && [District]=__District),
    [Amount]
  )

Sorry I forgot the ALLEXCEPT versus ALL earlier! 🙄



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@DeBIe ,Try

 

Min= Min('Table'[Amount])
Max = Max('Table'[Amount])

or
Min= CALCUALTE(Min('Table'[Amount]),allexcept(Table, Table[Supplier]))
Max = CALCUALTE(Max('Table'[Amount]),allexcept(Table, Table[Supplier]))

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

Hello @amitchandak ,

 

Thank you, the calculate formula works.

 

I need one additional filter to add to the logic. I also have a column with the district/region. Which means supplier Wallmart can appear in district A, B, C, etc. When I calculate the min and max amount, it needs to be the amount of that specific district. How can I add this to the existing formula? I think something like:

 

Min= CALCUALTE(Min('Table'[Amount]),allexcept(Table, Table[Supplier]) ,allexcept(Table, Table[District])

 

Thank you!

@DeBIe - Try:

Column =
  VAR __Supplier = [Supplier]
  VAR __District = [District]
  MINX(
    FILTER('Table',[Supplier]=__Supplier && [District]=__District),
    [Amount]
  )

Measure =
  VAR __Supplier = MAX([Supplier])
  VAR __District = MAX([District])
  MINX(
    FILTER(ALL('Table'),[Supplier]=__Supplier && [District]=__District),
    [Amount]
  )

Sorry I forgot the ALLEXCEPT versus ALL earlier! 🙄



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Community Champion
Community Champion

@DeBIe - 

Min Amount Supplier Column = MIN('Table'[Amount])

Max Amount Supplier Column = MAX('Table'[Amount])

Min Amount Supplier Measure = MINX(ALL('Table'),[Amount])

Max Amount Supplier Column = MAXX(ALL('Table'),[Amount])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.