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
mscantle
Helper I
Helper I

Lookup value in another table using multiple criteria, including a fixed value

Hi all,

 

I have one table that looks like this:

mscantle_0-1718277727849.png

And another table like this:

mscantle_2-1718277985280.png

 

The two tables are related via Idno.

I want to create a column in the first table that shows the English scores for those Idno at those dates. The result should be:

mscantle_3-1718278156962.png

I've tried various LOOKUP syntax but can't get it to work.

Thank you in advance for any ideas.

 

1 ACCEPTED SOLUTION

Hi @mscantle 

I adapted the measure as i forgot the date

I just tested and it works for me

 

Please try again

English Grade = 
CALCULATE (
    SUM('Table1'[Grade]), 
    FILTER (
        'Table1',
        'Table1'[Idno] = 'Table2'[Idno]
        && 'Table1'[Date] = 'Table2'[Date]
        && 'Table1'[Subject] = "English"))

Joe_Barry_0-1718355662095.png

 




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

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn
Let's connect on LinkedIn


View solution in original post

6 REPLIES 6
mscantle
Helper I
Helper I

That's fantastic - many thanks Joe!

Anonymous
Not applicable

Hi @mscantle 

 

Thanks for the reply from @Joe_Barry , please allow me to provide another insight:

First of all, open the Power Query, select the Subject column and click pivot column:

vzhengdxumsft_0-1718593551165.png

Then select the Grade in Values column and Don't Aggregate in another checkbox:

vzhengdxumsft_1-1718593650171.png

 

The result is as follow:

vzhengdxumsft_2-1718593697322.png

 

Or you can try this:

First of all, delete the relationship between the two table:

vzhengdxumsft_3-1718593763114.png

Then add a calculated column in table2:

English Grade =
VAR _vtable =
    FILTER (
        CROSSJOIN (
            SELECTCOLUMNS (
                'Table',
                "_Idno1", 'Table'[Idno],
                "_Date1", 'Table'[Date],
                "_Sub1", 'Table'[Subject],
                "_Grade", 'Table'[Grade]
            ),
            SELECTCOLUMNS ( 'Table2', "_Idno2", 'Table2'[Idno], "_Date2", 'Table2'[Date] )
        ),
        [_Date1] = [_Date2]
            && [_Idno1] = [_Idno2]
    )
RETURN
    SUMX (
        FILTER (
            _vtable,
            [_Idno1] = 'Table2'[Idno]
                && [_Date1] = 'Table2'[Date]
                && [_Sub1] = "English"
        ),
        [_Grade]
    )

The result is as follow:

vzhengdxumsft_4-1718593830763.png

 

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Uzi2019
Super User
Super User

Hi @mscantle 

 

If you want to just have english grade so just apply filter of english on table visual level . it auto shows english grade only.

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
Joe_Barry
Super User
Super User

Hi @mscantle 

 

Give this a try as a custom column.

 

English Grade = 
CALCULATE (
    SUM('Table2'[Grade]), 
    FILTER (
        'Table2',
        'Table2'[Idno] = 'Table1'[Idno]
        && 'Table2'[Subject] = "English"))

 

 

Hope this helps

 

Joe




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

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn
Let's connect on LinkedIn


Thanks Joe,

I tried this but I get an error message saying "A single value for 'Idno' in table 'Table2' cannot be determined. This can happen when a measure formula refers to a clumn that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."

I thought this might be because there is an English grade for each date for each Idno, so tries this:

 

English Grade=
CALCULATE(
    SUM('Table2'[Grade]),
    FILTER (
        'Table2',
        'Table2'[Idno] = 'Table1'[Idno]
        && 'Table2'[Date] = 'Table1'[Date]
        && 'Table2'[Subject]= "English"))
 
However, this gave the same error message.

Hi @mscantle 

I adapted the measure as i forgot the date

I just tested and it works for me

 

Please try again

English Grade = 
CALCULATE (
    SUM('Table1'[Grade]), 
    FILTER (
        'Table1',
        'Table1'[Idno] = 'Table2'[Idno]
        && 'Table1'[Date] = 'Table2'[Date]
        && 'Table1'[Subject] = "English"))

Joe_Barry_0-1718355662095.png

 




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

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn
Let's connect on LinkedIn


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.