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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Relation problem

I've got 2 tables

ActivityIDDateEmpIDEmpName
119-8-2020  3Jansen
220-8-2020  4de Boer
321-8-2020  5

Fransen

 

EmpIDEmpNameFunctionFromTo
3JansenPsycholoog1-1-202031-7-2020
3JansenGZ-Psycholoog1-8-2020 
4de BoerSchoonmaker1-1-2020 
5FransenController1-1-2020 

 

The relation is between EmpID fields. I want to add a column where I can see function of the employee on the date of the activity. What Dax formula can I use?

1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

Would you please try the calculated column below:

 

 

Function =
CALCULATE (
    CONCATENATEX ( VALUES ( Table2[Function] ), Table2[Function], "," ),
    FILTER (
        Table2,
        Table2[From] <= EARLIER ( 'Table'[Date] )
            && COALESCE ( Table2[To], TODAY () ) >= EARLIER ( 'Table'[Date] )
            && Table2[EmpID] = EARLIER ( 'Table'[EmpID] )
    )
)

 

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

4 REPLIES 4
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

Would you please try the calculated column below:

 

 

Function =
CALCULATE (
    CONCATENATEX ( VALUES ( Table2[Function] ), Table2[Function], "," ),
    FILTER (
        Table2,
        Table2[From] <= EARLIER ( 'Table'[Date] )
            && COALESCE ( Table2[To], TODAY () ) >= EARLIER ( 'Table'[Date] )
            && Table2[EmpID] = EARLIER ( 'Table'[EmpID] )
    )
)

 

 

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

 

Best Regards,

Dedmon Dai

Anonymous
Not applicable

Hi @v-deddai1-msft 

I tried your formula and I got some good answers but not everything is correct.

 

ActivityIDDateEmpIDEmpNameFunction
119-8-2020  3JansenGZ-psycholoog
220-8-2020  4de BoerSchoonmaker
321-8-2020  5Fransen 

 

I expected Controller in activity 3. Do you know what went wrong?

 

 

Edit: The issue was because the current date (20-8-2020) was before the date of the activity. I've changed the dates in the tables and everything worked, thanks!!!

amitchandak
Super User
Super User

@Anonymous , I did get you to need completely.

 

Try a new column in Table 1

maxx(filter(table2, table2[From]<=Table1[Date] && coalesce(table2[From],today())>=Table1[Date] ), table2[Function])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
ThoSch-Ger
Helper I
Helper I

Do you really need it inside the first table? If you do there is no more need for separate tables with a relationship since you have it all in one table.

 

I would recommend to match the data only in your report. that keeps your data model tidy and fast.

 

matrix visual:

Date rows I Employer Name column from table one

Function from table two

 

that should do it 

 

by the way you have a cardinality problem with employee jansen. he has two funktions with the same EmpID. I would recommend to give a new EmpID for the new qualification

 

cheers

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.