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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Combine multiple DISTINCT statements to get the MIN value

Hello everyone,

I'm new to the world of Power BI and I need your help.

My goal is to find the lowest value ('Price') filtered by a combination of two columns ('Product_ID' and 'Month Number'). Take this table as an example:

 

Total Sales Table:

Contract_IDProduct_IDMonth_NumberPrice 
01100112,34
02100112,22
03100112,45
04100122,19
05100122,37
06200225,69
07200225,14
And so on.........

 

That is what I want to achive:

Contract_IDProduct_IDMonth_NumberPrice 

Best_Price per
Product and Month

01100112,342,22
02100112,222,22
03100112,452,22
04100122,192,19
05100122,372,19
06200225,695,14
07200225,145,14
And so on............

 

This is what I had tried, but it didn't work:

Best_Price per Product and Month =
CALCULATE(
MINX(Total_Sales, Total_Sales[Price]),
DISTINCT(Total_Sales[Product_ID]),
DISTINCT(Total_Sales[Month_Number]
)

 

Any sugesstions / ideas how to solve that issue? 

You would help me a lot! Thanks in advance 🙏

 

Best,

Felix

 

1 ACCEPTED SOLUTION
edhans
Community Champion
Community Champion

See if this works for you:

Best Price = 
    CALCULATE(
        MIN('Table'[Price ]),
        REMOVEFILTERS('Table'[Contract_ID], 'Table'[Price ])
    )

edhans_0-1624644657991.png
Because Month is a number and the way you have your data @Anonymous , you ned to make sure that the column is not summarized or the results will not be correct. 

edhans_1-1624644777983.png

 

 



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

View solution in original post

5 REPLIES 5
edhans
Community Champion
Community Champion

See if this works for you:

Best Price = 
    CALCULATE(
        MIN('Table'[Price ]),
        REMOVEFILTERS('Table'[Contract_ID], 'Table'[Price ])
    )

edhans_0-1624644657991.png
Because Month is a number and the way you have your data @Anonymous , you ned to make sure that the column is not summarized or the results will not be correct. 

edhans_1-1624644777983.png

 

 



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 help! (Sry for the late reply, I was on vacation.)

 

I testet your solution on a small "testing data set" and it worked completly fine, but not on my "real" data set I'm working on.

 

Could you explain why you've selected the column 'Contract ID' for the REMOVEFILTERS function?

 

Best,

Felix

edhans
Community Champion
Community Champion

Hi @Anonymous  - sorry just getting back to you. Missed the notification.

I didn't want the filter context from the table visual that was passing the current contract ID to affect the measure, so I removed that filter. The measure looks at all contract IDs to get the results. It keeps the filters though for the month ID and product.



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

This explanation was super helpful!

I used the function ALLEXCEPT to solve my problem, but without you I would not have figured it out. Thanks! 💛

edhans
Community Champion
Community Champion

Great @Anonymous !

Yup - ALLEXCEPT, REMOVEFILTERS, ALL, etc. within CALCULATE are different ways of doing the same thing depending on the circumstances. ALLEXCEPT can be more efficient depending on how many fields you have to remove the filters on.



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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.