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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
DarylRob
Helper I
Helper I

Lookup closest value in table from parameter

So I've got a what if parameter where the user enters a value, I then want to lookup this value in a table of 1000 values and then return another column from the row with the closest value

I.e the table is

1100,000
2350,000
320,000
4478,000

 

The user would enter 290,000 and it return 2. Is this possible?

 

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @DarylRob ,

 

You can achieve this by using a difference between the what if and the table if you setup somehting similart to this:

 

Closest value =
VAR temptable =
    TOPN (
        1,
        ADDCOLUMNS (
            Table,
            "@Difference", ABS ( Table[Value] - 'Parameter'[Parater Value] )
        ),
        [@Difference], ASC
    ) 
RETURN
    MINX ( temptable, Table[ID] )

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @DarylRob ,

 

You can achieve this by using a difference between the what if and the table if you setup somehting similart to this:

 

Closest value =
VAR temptable =
    TOPN (
        1,
        ADDCOLUMNS (
            Table,
            "@Difference", ABS ( Table[Value] - 'Parameter'[Parater Value] )
        ),
        [@Difference], ASC
    ) 
RETURN
    MINX ( temptable, Table[ID] )

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



This is perfect, thank you

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors