Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Hi there,
I'm having trouble to find the next highest value in a column.
In one table i have the actual zone and number of kilo's in a row. I need a calculated column (or by measure) to calculate the rate for that specific row. The kilo's, zone and rate are in a separate table and that table looks like below.
| KG | Zone | Rate |
| 1 | 1 | 6.29 |
| 1 | 2 | 8.50 |
| 1 | 3 | 9.00 |
| 2 | 1 | 6.75 |
| 2 | 2 | 9.25 |
| 2 | 3 | 10.00 |
| 3 | 1 | 8.50 |
| 3 | 2 | 10.00 |
| 5 | 3 | 11.00 |
| 7 | 1 | 9.50 |
| 8 | 2 | 11.50 |
| 9 | 3 | 13.00 |
Example: if KG = 2.5 & zone = 2 is should select the rate of 10.00. This means that it needs to look at the table and if the specific weight is not available it must look to the next highest value within that zone and select that rate. In this case it is rounding 2.5 to 3.
Example 2: if KG = 6 & zone = 3 is should select the rate of 13.00.
I was able to make the calculated column myself but only when the weight was exactly matching the KG in the column. The issue i'm having is that i'm not able to write the code to look for the next highest value in the column based on another column.
Solved! Go to Solution.
Hi, @Anonymous
You can try the following methods.
Table1:
Table2:
Column =
Var _nexthighKG=CALCULATE(MIN(Table1[KG]),FILTER(Table1,[KG]>=EARLIER(Table2[KG])&&[Zone]=EARLIER(Table2[Zone])))
Return
CALCULATE(MAX(Table1[Rate]),FILTER(Table1,[KG]=_nexthighKG&&[Zone]=EARLIER(Table2[Zone])))
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
After the weekend, with a fresh mind, i tried it again and it seems i made a mistake the first time.
This is working.
Thank you @v-zhangti
Hi @v-zhangti
Thank you for your help.
I applied the provided code but i gives an error "EARLIER/EARLIEST refers to an earlier row context which doesn't exist"
Hi, @Anonymous
You can try the following methods.
Table1:
Table2:
Column =
Var _nexthighKG=CALCULATE(MIN(Table1[KG]),FILTER(Table1,[KG]>=EARLIER(Table2[KG])&&[Zone]=EARLIER(Table2[Zone])))
Return
CALCULATE(MAX(Table1[Rate]),FILTER(Table1,[KG]=_nexthighKG&&[Zone]=EARLIER(Table2[Zone])))
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the April 2026 Power BI update to learn about new features.
If 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.
| User | Count |
|---|---|
| 41 | |
| 37 | |
| 34 | |
| 21 | |
| 16 |
| User | Count |
|---|---|
| 66 | |
| 58 | |
| 31 | |
| 25 | |
| 24 |