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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
tdoth1995
Regular Visitor

Using LOOKUPVALUE with multiple conditions, returns one value if only one condition met

Not sure of the best way to describe the problem or even how to approach solving this but let me try my best. 

 

I'm using LOOKUPVALUE to pull a value based on two columns: [Defect] and [Location] which gives me a numerical value. This works fine, but I only have data for around 80% of the data. i.e. the defect location may have 50 total values but I've only collected data for 10.

 

This is how the formula looks like:

Rework (s) = LOOKUPVALUE('Defect x Location'[Average Re-Work Time (Per Unit) in seconds], 'Defect x Location'[Defect location], 'QC Database'[Location], 'Defect x Location'[Defect Name], 'QC Database'[Defect])
 

 This is the table I'm pulling the lookup value from:

tdoth1995_0-1684960838686.png


What I'm trying to achieve is if the lookup value meets the first requirement of the "Defect Name" column, but not the "Defect Location" column, it automatically defaults to using the "Defect Location" value of other. 

 

For example, I'm looking to pull up a value of

         [defect]"Open Lamination" and [Locaion]"Yoke".

Since there is no value for this in my lookuptable, I want it to automatically refer to using the value listed in
                 [defect]"Open Lamination" and [Location]"Other"

If it helps, this value is just an average of the values listed for that particular defect. Let me know if I've explained that well but not sure which functions I would even use to approach this type of problem. Let me know if there's anything I need to give clarification on that make it easier to support me.


Thank you:)

 

1 ACCEPTED SOLUTION
jgeddes
Super User
Super User

You can try to add a conditional 'location' variable in your calculated column.
Something along the lines of...

Average = 
var _location =
IF(
    ISBLANK(
        LOOKUPVALUE('Table A'[Location], 'Table A'[Name], 'Table B'[Name], 'Table A'[Location], 'Table B'[Location])
    ),
    "Other",
    [Location]
)
Return
LOOKUPVALUE(
    'Table A'[Avg],
    'Table A'[Name], 'Table B'[Name],
    'Table A'[Location], _location
)

Basically you are performing the lookup twice. The first time to see if the location returns a blank. The second time returns the rework time using 'Other' if needed.





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

Proud to be a Super User!





View solution in original post

3 REPLIES 3
jgeddes
Super User
Super User

You can try to add a conditional 'location' variable in your calculated column.
Something along the lines of...

Average = 
var _location =
IF(
    ISBLANK(
        LOOKUPVALUE('Table A'[Location], 'Table A'[Name], 'Table B'[Name], 'Table A'[Location], 'Table B'[Location])
    ),
    "Other",
    [Location]
)
Return
LOOKUPVALUE(
    'Table A'[Avg],
    'Table A'[Name], 'Table B'[Name],
    'Table A'[Location], _location
)

Basically you are performing the lookup twice. The first time to see if the location returns a blank. The second time returns the rework time using 'Other' if needed.





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

Proud to be a Super User!





Never mind! I see where my mistake was, you were just shortening some of the variables I had given you and the variables from the two tables were differing in my formula. 

This solution worked quite well for what I needed it for. Thank you!

Thanks for the quick response. Could you elaborate a little further on a couple of points:

1. 

Average = 
var _location =

 Where is this coming from? 

2. IS Table A the table that I'm trying to perform the lookupvalue from and Table B the table that I have the calculated column in? Or vice-versa.

3. 

'Table A'[Avg],


Is this coming from the "Average" value that was just calculated in the introduced _location variable?

Just for clarity for me: Can you refer to the table being looked up as "Table Lookup" and the table which the calculated column is being put into as "QC Database".


Thanks again!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.