Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have a dataset that looks like the table below. I'm trying to build a measure that will let me calculate the smallest difference between an amount and any other amount in that table. I'd then like to return the name that generated the smallest value.
Name | Amount |
A | 1 |
B | 4 |
C | 9 |
D | 16 |
For example:
For Name A, the minimum difference calculated is 3 (4-1; 9-1; 16-1) and that corresponds with B.
For Name C, the minimum difference calculated is -8 (1-9; 4-9; 16-9) which corresponds with A.
Any idea on how I can create a measure that does the amount difference calculation iterating across the entire table (all other amounts less current row amount) as well as a measure that returns the corresponding name for that minimum difference?
Thank you in advance
I believe this measure will do what you are looking for. I made a table called 'Data' with your values. Also included comments on each line to explain how it works.
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Hi @akarasick1 ,
Its quite a tricky problem and requires to be solved via relationship.
Your Original Table:
Table2
1. Create a new Table:
3. Create a Summary Table:
Thank you for all of your effort! I'm worried that joining based on amount will cause some issues if the amounts are the same for more than one value. Any thoughts on that?
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
9 | |
8 | |
8 | |
8 |
User | Count |
---|---|
14 | |
12 | |
11 | |
10 | |
9 |