cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TrentS Regular Visitor
Regular Visitor

Lookupvalue help

I am returning to a previous issue (https://community.powerbi.com/t5/Desktop/Logic-help-IF-Switch-Contains/m-p/622072#M296983) with an update. (Thanks Greg for that previous help.)

It works with the exception of the new entries into the database. Those are just left blank when it should return the original search value (the new entry) when it does not find it in the Excel source.

 

The measure I created  = LOOKUPVALUE(Excel[Clean_Name], Excel[Customer_Name], Server[Customer_Name]) does the job of retrieving the Clean name as expected. To use my example from the previous post, the slicer returns only 'ACME' instead of listing ACME Inc., Acme, Co., etc.

However, a new entry into the db, let's say Acme LLC, is left blank in the table and not displayed in the filter even though the record can be located in the data.

Adding the alternate clause in the LOOKUPVALUE function such as "False Account" works and any blanks get filled. I would like it to return the original search value, the new db entry (Acme LLC). The slicer would show both "Acme" and "Acme LLC" until the quarterly review of the Excel file and the Acme LLC entry is updated.

When I add the reference to it:

= LOOKUPVALUE(Excel[Clean_Name], Excel[Customer_Name], Server[Customer_Name], Server[Customer_Name])

 

I get the error "A single value for column 'Customer_Name' in table 'Sudden Impact Reporting' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."

 

The base logic behind this is

1. Compare the Server[Customer_Name] with Excel[Customer_Name

2. If found, return Excel[Clean_Name]

3. If not return Server[Customer_Name]

 

Is it just syntax that I have wrong or am I missing another statement in this?

 

1 ACCEPTED SOLUTION

Accepted Solutions
TrentS Regular Visitor
Regular Visitor

Re: Lookupvalue help

Thanks JSH, I will experiment with that. Might be a cleaner method and I can gain some education in it.

I did find a solution just a minute ago. A combination of IF and ISBLANK works.

= IF(
ISBLANK(
LOOKUPVALUE(Excel[Clean_Name], Excel[Customer_Name], 'Server'[Customer_Name])
), 'Server'[Customer_Name],
LOOKUPVALUE(Excel[Clean_Name], Excel[Customer_Name], 'Server'[Customer_Name])
), 'Server'[Customer_Name]
))
6 REPLIES 6
Highlighted
jsh121988 Regular Visitor
Regular Visitor

Re: Lookupvalue help

I didn't read your whole issue, but I read your logic and summary. Try this:

CalcColumn = // On the Server table 
VAR sCleanName = LOOKUPVALUE(Excel[Clean_Name], Excel[Customer_Name], Server[Customer_Name], "NotFound")

RETURN IF(sCleanName = "NotFound", Server[Customer_Name], sCleanName)

 

TrentS Regular Visitor
Regular Visitor

Re: Lookupvalue help

Thanks JSH, I will experiment with that. Might be a cleaner method and I can gain some education in it.

I did find a solution just a minute ago. A combination of IF and ISBLANK works.

= IF(
ISBLANK(
LOOKUPVALUE(Excel[Clean_Name], Excel[Customer_Name], 'Server'[Customer_Name])
), 'Server'[Customer_Name],
LOOKUPVALUE(Excel[Clean_Name], Excel[Customer_Name], 'Server'[Customer_Name])
), 'Server'[Customer_Name]
))
smuthukumar Frequent Visitor
Frequent Visitor

Re: Lookupvalue help

Hey @TrentS

 

I am also facing a similar problem and I tried the solution you had suggested. I am getting this error "A table of multiple values was supplied where a single value was expected. " 

This is what i am trying to do: I am trying to do a lookup with if condition where, if there is a match between ID from table 1 and table 2, i get the corresponding status if not i assign a value, else if there is a match but the status column is empty then i have to assign a new value. 

 

I have two tables: table1 and table 2
table 2 has ID, status

table 1 has ID

column = 

column = IF(ISBLANK(
LOOKUPVALUE('table2'[status], 'table2'[ID], 'table1'[ID])
), "No", LOOKUPVALUE('table2'[status], 'table2'[ID], 'table1'[ID])
)
 
i also used this formula : 
column  =
var lookup =
LOOKUPVALUE('table2'[status], 'table2'[ID], 'table1'[ID])
var compareVaraiable = BLANK()
return
IF(lookup = compareVaraiable, "No")

I have also attached the pbix file here. It would be great if you have ideas to resolve this!
TrentS Regular Visitor
Regular Visitor

Re: Lookupvalue help

Hi @smuthukumar ,

 

I created a plain pbix to test the syntax/logic and it seemed to work fine with both a value (7) not found in table and a value with a blank status.

lookup.PNG

I will try to take a peek at your file here shortly.

 

TrentS

smuthukumar Frequent Visitor
Frequent Visitor

Re: Lookupvalue help

Thank you @TrentS! I also tried it in another sample file and the following logic works fine.

 

new status =
var lookup =
LOOKUPVALUE('table2'[status], 'table2'[ID], 'table1'[ID])
var compareVaraiable = BLANK()
return
IF(lookup = compareVaraiable, "No ", lookup)
 

I was able to assign values.  In that case,  am not sure why its not working for my main file. Do you have any guesses? The error is "A table of multiple values was supplied where a single value was expected."

 

Thanks for your help!

Super User
Super User

Re: Lookupvalue help

Hi,

That error means that there are repetitions in the ID column  on Table2.

Helpful resources

Announcements
Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

PBI Community Highlights

PBI Community Highlights

Check out what's new in the Power BI Community!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 96 members 1,594 guests
Please welcome our newest community members: