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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
diablo9081
Frequent Visitor

Lookup Value From Within Virtual Table

I need some help with how to lookup a value from within a virtual table. LOOKUPVALUE doesn't seem to work with virtual tables.

 

I've got the following:

DEFINE
VAR __DS0Core = 
	SUMMARIZECOLUMNS(
		'DASHBOARD_VW'[_Clinic_Decode],
		"v_Charting_X", '_Measures'[_Charting_X],
		"v_Charting_Y", '_Measures'[_Charting_Y]
	)

VAR __DataTransformT0 =
	{
		KMeansClustering(
		SELECTCOLUMNS(
			__DS0Core,
			"v_Clinic_Decode", 'DASHBOARD_VW'[_Clinic_Decode],
			"v_Charting_X", '_Measures'[_Charting_X],
			"v_Charting_Y", '_Measures'[_Charting_Y]
		),
		{("[v_Charting_X]", "Attribute"),
			("[v_Charting_Y]", "Attribute"),
			("[v_Clinic_Decode]", "Item")},
		{("[v_Clinic_Decode]", BLANK()),
			("ClusterId", "ClusterId")},
		-1
		)
	}

 
I end up with a virtual table __DataTransformT0 with two columns, [v_Clinic_Decode] and [ClusterId]. How can I lookup the [ClusterId] column value using the [v_Clinic_Decode] value from within this virtual table? LOOKUPVALUE works when the table is in the model, but it's just a virtual table here.

v_Clinic_DecodeClusterId
x12342
b12373
d23561
1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @diablo9081 

You could perform a lookup-equivalent with an expression like this:

SELECTCOLUMNS (
    FILTER ( __DataTransformT0, [v_Clinic_Decode] = "<LOOKUP_VALUE>" ),
    [ClusterId]
)

Assuming __DataTransformT0 is guaranteed to contain at most one row per v_Clinic_Decode (which should be the case here), this would return a 1x1 table (or BLANK) which is automatically converted to a scalar value where required.

 

Alternatively, you could consider using DEFINE TABLE rather than DEFINE VAR for __DataTransformT0 which would create a table for the duration of the query. You could then reference this table as though it were a model table in an expression like this:

LOOKUPVALUE (
    __DataTransformT0[ClusterId],
    __DataTransformT0[v_Clinic_Decode], "<LOOKUP_VALUE>" )
)

See here.


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

3 REPLIES 3
v-ssriganesh
Community Support
Community Support

Hello @diablo9081,

We hope you're doing well. Could you please confirm whether your issue has been resolved or if you're still facing challenges? Your update will be valuable to the community and may assist others with similar concerns.

Thank you.

 

v-priyankata
Community Support
Community Support

Hi @diablo9081 

Thank you for reaching out to the Microsoft Fabric Forum Community.

@OwenAuger Thanks for the inputs.

I hope the information provided by users was helpful. If you still have questions, please don't hesitate to reach out to the community.

 

OwenAuger
Super User
Super User

Hi @diablo9081 

You could perform a lookup-equivalent with an expression like this:

SELECTCOLUMNS (
    FILTER ( __DataTransformT0, [v_Clinic_Decode] = "<LOOKUP_VALUE>" ),
    [ClusterId]
)

Assuming __DataTransformT0 is guaranteed to contain at most one row per v_Clinic_Decode (which should be the case here), this would return a 1x1 table (or BLANK) which is automatically converted to a scalar value where required.

 

Alternatively, you could consider using DEFINE TABLE rather than DEFINE VAR for __DataTransformT0 which would create a table for the duration of the query. You could then reference this table as though it were a model table in an expression like this:

LOOKUPVALUE (
    __DataTransformT0[ClusterId],
    __DataTransformT0[v_Clinic_Decode], "<LOOKUP_VALUE>" )
)

See here.


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.