Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
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_ID | Product_ID | Month_Number | Price |
| 01 | 1001 | 1 | 2,34 |
| 02 | 1001 | 1 | 2,22 |
| 03 | 1001 | 1 | 2,45 |
| 04 | 1001 | 2 | 2,19 |
| 05 | 1001 | 2 | 2,37 |
| 06 | 2002 | 2 | 5,69 |
| 07 | 2002 | 2 | 5,14 |
| And so on | ... | ... | ... |
That is what I want to achive:
| Contract_ID | Product_ID | Month_Number | Price | Best_Price per |
| 01 | 1001 | 1 | 2,34 | 2,22 |
| 02 | 1001 | 1 | 2,22 | 2,22 |
| 03 | 1001 | 1 | 2,45 | 2,22 |
| 04 | 1001 | 2 | 2,19 | 2,19 |
| 05 | 1001 | 2 | 2,37 | 2,19 |
| 06 | 2002 | 2 | 5,69 | 5,14 |
| 07 | 2002 | 2 | 5,14 | 5,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
Solved! Go to Solution.
See if this works for you:
Best Price =
CALCULATE(
MIN('Table'[Price ]),
REMOVEFILTERS('Table'[Contract_ID], 'Table'[Price ])
)
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.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingSee if this works for you:
Best Price =
CALCULATE(
MIN('Table'[Price ]),
REMOVEFILTERS('Table'[Contract_ID], 'Table'[Price ])
)
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.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingThanks 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
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.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingThis explanation was super helpful!
I used the function ALLEXCEPT to solve my problem, but without you I would not have figured it out. Thanks! 💛
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.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingIf you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 9 | |
| 8 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 23 | |
| 14 | |
| 10 | |
| 6 | |
| 5 |