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
Anonymous
Not applicable

Tried Lookup But Error "a table of multiple values was supplied where a single value was expected"

Hi,

 

Below is the Data and I was trying to get the Manager Territory and  True / False as shown in the below Table:

 

Requirements are:

1. Manager Territory should get populated by Looking the Manager ID in Column "ID" and get the respective Territory ID from Column "Territory Id"

2. Now the Calculated Column "Manager ID" should be matched with column "Parent Territory Id" to flag the true or false. We are doing this since there is a possibility that the Parent Territory ID is wrong mapped for ID. 

For example: ID = 3, his Manage is 7 and Parent Territory id is A005. But the correct parent territory id is A006.

Note: If we are not able to get the Manager ID column, we can ignore it. But we need the Flagging column, whether it is True or False.

 

Challenges:

One ID (can be manager as well) can have 2 or more territories. So it should be true if the Parent Territory ID falls in any of the Manager ID of the respective Manager.

 

Thanks a lot in advance.

 

Data:

IdNameTerritory IdParent Territory IdManager IDManager NameManager Territory (Calculated Field)True / False (Calculated Field)
1AA001A0055EE TRUE
2BA002A0056FF TRUE
3CA003A0057GG FALSE
3CA004A0078GG TRUE
4DA003A0099II FALSE
5EEA005A0099100JJJ  
6FFA005A005555EEE  
7GGA006A005566FFF  
8GGA007A008899III  
9IIA008A0099100JJJ  
10JJA009A005555EEE  
1 REPLY 1
lbendlin
Super User
Super User

@Anonymous You didn't specify if you want this in DAX or Power Query.  Here's a Power Query version.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dY87C8IwFIX/SsncIWntw1HtgxQUB7fSIWAQByuELv577yOYWHG4Ock9Xy7njqPQV5GKk3lYkIt17r483Suh7tk4Oy/Jqns0s7lZl+gmetCAKR2FguYOS0rFUoBgtS0BGVz37GQBKKG6joAcrgd28gBUUH2/BjYsaNYBwG7zNWELgqU1AT7OZzgSaCsp4RyGgSifKaYKWoa/8zo+F7llBJX8m1eqI6hiqbG35Uwcyudj928oxY+w1m+q6Q0=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t, #"(blank).4" = _t, #"(blank).5" = _t]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Added Custom" = Table.AddColumn(#"Promoted Headers", "Manager Territory", each try (Table.SelectRows(#"Promoted Headers",(k)=> k[Id]=[Manager ID]))[Territory Id]{0} otherwise null),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Matching", each [Parent Territory Id]=[Manager Territory])
in
    #"Added Custom1"

How to use this code: Create a new Blank Query, then click on "Advanced Editor", and then replace the code in the window with the code provided here. Then click "Done".

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.