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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
htsvhwave
Helper II
Helper II

Return a value from another tabel based on multiple conditions

Hi

 

I have to tables, in my first tabel i want to return a value from the second tabel. I need to look up the amount of vacation left for december. In this example i have only shown one user however in my real dataset i have mulitple users. Inmy column the code need to match the following

tabel1 date =  tabel 

 

Tabel 1

User IDDateVacation left
AKLK31-12-2023 

Tabel 2

USer IDDateTypes of overtimeAmount
AKLK31-12-2023Vacation4
AKLK31-12-2023Paidovertime6
AKLK30-11-2023Vacation2
AKLK30-11-2023Paidovertime5
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @htsvhwave ,

You can follow the steps below to get it:

1. Create the relationship between Table 1 and Table 2 base on the field [User ID]

vyiruanmsft_0-1705566745718.png

2. Create a calculated column as below in Table 1 to get it

Vacation left =
CALCULATE (
    SUM ( 'Table 2'[Amount] ),
    FILTER ( 'Table 2', 'Table 2'[Date] = EARLIER ( 'Table 1'[Date] ) )
)

vyiruanmsft_1-1705566823608.png

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @htsvhwave ,

You can follow the steps below to get it:

1. Create the relationship between Table 1 and Table 2 base on the field [User ID]

vyiruanmsft_0-1705566745718.png

2. Create a calculated column as below in Table 1 to get it

Vacation left =
CALCULATE (
    SUM ( 'Table 2'[Amount] ),
    FILTER ( 'Table 2', 'Table 2'[Date] = EARLIER ( 'Table 1'[Date] ) )
)

vyiruanmsft_1-1705566823608.png

Best Regards

zenisekd
Super User
Super User

To me, the easiest way would be to merge the two tables in Power Query, based on two key columns - User ID and Date (when in merge, hold CTR and select columns in the table, which are used for merge). Power BI modeling doesn't allow relationship, based on 2 columns.

Or you could also create a new key column, which would be made of USER ID and Date combination in both tables. Then you could use this new column for relationship. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors