Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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?
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
25 | |
10 | |
7 | |
6 | |
6 |
User | Count |
---|---|
30 | |
11 | |
11 | |
10 | |
6 |