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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Hayashi123
New Member

Lookup in another table and then net results if applicable

Hi. New to Power BI and would appreciate any advice and guidance on this.

 

I am trying to lookup the Buy User Ids in Table 1 in Table 2 and if the Buy User ID is in Table 1 matches the Sell User ID in Table 2 then net the Amounts and gives the "Exp Results" in Table 1.

 

 

 

Hayashi123_0-1710085799344.png

 

 

2 ACCEPTED SOLUTIONS
Dangar332
Super User
Super User

HI, @Hayashi123 

 

your information is not appropriate but try below

first make sure sellerid and user id tables is connected with eachother
and use below code for new column

 

Column = 
var a = LOOKUPVALUE(seller[amount],seller[sellerid],user[userid])
return
user[amount]-a

 

 

Dangar332_0-1710087875632.png

 

 

View solution in original post

Anonymous
Not applicable

HI @Hayashi123,

Perhaps you can try to use the IN operator to compare the selected value and calculate with current values.
Measure formula sample :

formula =
VAR currAmount =
    SUM ( User[amount] )
VAR selected =
    CALCULATE (
        SUM ( Seller[Amount] ),
        FILTER ( ALLSELECTED ( Seller ), [User ID] IN VALUES ( User[User ID] ) )
    )
RETURN
    currAmount - selected

The IN operator in DAX - SQLBI

Regards,

Xiaoxin Sheng

View solution in original post

4 REPLIES 4
Dangar332
Super User
Super User

HI, @Hayashi123 

 

your information is not appropriate but try below

first make sure sellerid and user id tables is connected with eachother
and use below code for new column

 

Column = 
var a = LOOKUPVALUE(seller[amount],seller[sellerid],user[userid])
return
user[amount]-a

 

 

Dangar332_0-1710087875632.png

 

 

Thank you for your reply.  It worked however, I wanted to do a sum lookup.  So in the Seller table there could be multiple rows with a Seller User ID and varying amounts.  

Anonymous
Not applicable

HI @Hayashi123,

Perhaps you can try to use the IN operator to compare the selected value and calculate with current values.
Measure formula sample :

formula =
VAR currAmount =
    SUM ( User[amount] )
VAR selected =
    CALCULATE (
        SUM ( Seller[Amount] ),
        FILTER ( ALLSELECTED ( Seller ), [User ID] IN VALUES ( User[User ID] ) )
    )
RETURN
    currAmount - selected

The IN operator in DAX - SQLBI

Regards,

Xiaoxin Sheng

StrategicSavvy
Resolver II
Resolver II

hi @Hayashi123 

I think you need provide more context because I cannot understand the logic of expected results. But if you would like to lookup you will have 2 options:

1. Create one to one relationship between buer and seller - my assumtions is they have 1-1 relationship based on your case. Then you can create either create measure that will calculate lookup value or create column in your table A with RELATED formula

 

2. Use merge operation in Power Query to join two datasets and name new column as Exp Results.

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: www.linkedin.com/in/lukasz-kozdron 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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