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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

LOOKUPVALUE - "A table of multiple values was supplied where a single value was expected"

Hi All, 

 

I've read all of the previous threads in regards to this issue however I did not find any good solution that works for my setup. 

 

I have two tables:

 

Sheet 1:

Change Date           ID

05 May 2019123
05 May 2018123
03 February 2019567

 

Sheet 2:

ID      Start Date             End Date                   Name

12301 January 201931 December 9999Red
12301 January 201831 December 2018Blue
56701 January 201831 December 9999Orange

 

I want to create a calculated column that returns the Name in Table 1 for each ID that falls into the date range. 

 

Sheet 1 including calculated column should look like that:

Change Date           ID    Name

05 May 2019123Red
05 May 2018123Blue
03 February 2019567Orange

 

I have tried the following two approaches:

1:

Calc Name 1 = CALCULATE(Values(Sheet2[Name]),
FILTER(
ALL(Sheet2),
AND(Sheet1[Change Date] >= Sheet2[Start Date], Sheet1[Change Date] <= Sheet2[End Date])))
 
2:
Calc Name 2 = IF(
AND(Sheet1[Change Date]>= MIN (Sheet2[Start Date]),Sheet1[Change Date]<= Max (Sheet2[End Date])),
LOOKUPVALUE(Sheet2[Name],Sheet2[ID],Sheet1[ID]),BLANK())

 

Calc Name 1 works if I put a filter on Query for Sheet 2 to display only one of the IDs e.g. 123.

The moment I take off the filter in the query I get multiple values returned instead of the one that was expected.

 

What step am I missing here?

 

Thanks!

 

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

Try this revision

 

Calc Name 1 =
CONCATENATEX (
    CALCULATETABLE (
        VALUES ( Sheet2[Name] ),
        FILTER (
            ALL ( Sheet2 ),
            Sheet1[Change Date] >= Sheet2[Start Date]
                && Sheet1[Change Date] <= Sheet2[End Date]
                && Sheet1[id] = Sheet2[id]
        )
    ),
    [Name],
    ","
)

Regards
Zubair

Please try my custom visuals

View solution in original post

3 REPLIES 3
RodrigoMachado
Frequent Visitor

That worked for me too! I had a very similar issue, and I alse was trying to use a DAX very similar to what @Anonymous was trying. It is funny how we cannot use something like LOOKUPVALUE to achieve those needs of retrieving certain values... In excel, a PROVC would do the work

Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

Try this revision

 

Calc Name 1 =
CONCATENATEX (
    CALCULATETABLE (
        VALUES ( Sheet2[Name] ),
        FILTER (
            ALL ( Sheet2 ),
            Sheet1[Change Date] >= Sheet2[Start Date]
                && Sheet1[Change Date] <= Sheet2[End Date]
                && Sheet1[id] = Sheet2[id]
        )
    ),
    [Name],
    ","
)

Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

Terrific it works! 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.