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

How to combine 3 values with diferent dates?

I have 3 tabels 

ID StartDateEndDateSortContractDuty
5025381-1-202231-12-2099Permanent3499

 

ID StartDateHoursEndDateHoursHours
5025381-1-202215-2-202220
50253816-2-202231-12-202215
5025381-1-202330-6-202325
5025381-7-202331-12-209930

 

ID StartDateHoursEndDateHoursCompany
5025381-1-202231-12-2022Boat
5025381-1-202331-8-2024Bike
5025381-9-202431-12-2099Car

 

Now I want to see in a visual:

 jan-22jan-23jan-24
SortContractPermanentPermanentPermanent
Duty349934993499
Hours202530
CompanyBoatBikeBike

 

I have a Calendar to connect to in a semantic model. But I can only connect with one tabel.
How can I get the wanted result? 

 

 

 

 

 

 

 

 

 

5 REPLIES 5
Anonymous
Not applicable

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

Hi, @JoseHop 

 

rajendraongole1's method is a good solution. If their solution has helped you, please accept their post as the solution.

vlinyulumsft_0-1732589794851.png

Here is my solution:

 

1.Firstly, I created the following table and filled in the values you need.

vlinyulumsft_1-1732589794852.png

2.Secondly, I created the following calculated columns based on your requirements.

SortContract = 
CALCULATE (
    MAX ( 'Table'[SortContract] ),
    FILTER (
        'Table',
        'Table'[StartDate] <= 'final'[date]
            && 'Table'[EndDate] >= 'final'[date]
    )
)
Duty = 
CALCULATE (
    MAX ( 'Table'[Duty] ),
    FILTER (
        'Table',
        'Table'[StartDate] <= 'final'[date]
            && 'Table'[EndDate] >= 'final'[date]
    )
)
Hours = 
CALCULATE (
    MAX ( 'Table (2)'[Hours] ),
    FILTER (
        'Table (2)',
        'Table (2)'[StartDateHours] <= 'final'[date]
            && 'Table (2)'[EndDateHours] >= 'final'[date]
    )
)
Company = 
CALCULATE (
    MAX ( 'Table (3)'[Company] ),
    FILTER (
        'Table (3)',
        'Table (3)'[StartDateHours] <= 'final'[date]
            && 'Table (3)'[EndDateHours] >= 'final'[date]
    )
)

3.Lastly, I created the following calculated table.

FTable = 
UNION (
    SELECTCOLUMNS (
        'final',
        'final'[date],
        "type", "SortContract",
        'final'[SortContract]
    ),
    SELECTCOLUMNS ( 'final', 'final'[date], "type", "Duty", 'final'[Duty] ),
    SELECTCOLUMNS ( 'final', 'final'[date], "type", "Company", 'final'[Company] ),
    SELECTCOLUMNS ( 'final', 'final'[date], "type", "Hours", 'final'[Hours] )
)

4.Here's my final result, which I hope meets your requirements.

vlinyulumsft_2-1732589927726.png

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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

 

Hi @Anonymous, 
Thank you for this solution.
Apologies for the late response.
I have not yet managed to implement your solution.
Now I discovered that I forgot an important part:
It is about creating this overview per ID. The ID is a person.
There is only 1 person in the example (5025381). In my data I have 3000 persons.
So I would like to know this per person.
How do I have to adjust your solution?


ID/ Persontypejan-22jan-23jan-24
5025381CompanyBoatBikeBike
5025381Duty349934993499
5025381hours202530
5025381sortContractPermanentPermanentPermanent



 

@Anonymous Could you look into this please? 
Thank you for your help so far, Jose

Anonymous
Not applicable

Hi, @JoseHop 

Thank you for your prompt response.

 

Here is the solution based on your latest requirements:

 

1.Firstly, we will create a date table to retain the time you need on the visual object, named datetable:

vlinyulumsft_0-1735018605410.png

2.Secondly, create the following calculated table to aggregate all the data as an intermediate table:

TF = CROSSJOIN(VALUES('datetable'[date]),VALUES('Table'[ID]))

3.Next, use the following calculated columns:

Company1 =
CALCULATE (
    MAX ( 'Table (3)'[Company] ),
    FILTER (
        'Table (3)',
        'Table (3)'[StartDateHours] <= 'TF'[date]
            && 'Table (3)'[EndDateHours] >= 'TF'[date]
            && 'Table (3)'[ID] = EARLIER ( 'TF'[ID] )
    )
)
Duty1 =
CALCULATE (
    MAX ( 'Table'[Duty] ),
    FILTER (
        'Table',
        'Table'[StartDate] <= 'TF'[date]
            && 'Table'[EndDate] >= 'TF'[date]
            && 'Table'[ID] = EARLIER ( 'TF'[ID] )
    )
)
Hours1 =
CALCULATE (
    MAX ( 'Table (2)'[Hours] ),
    FILTER (
        'Table (2)',
        'Table (2)'[StartDateHours] <= 'TF'[date]
            && 'Table (2)'[EndDateHours] >= 'TF'[date]
            && 'Table (2)'[ID] = EARLIER ( 'TF'[ID] )
    )
)
SortContract1 =
CALCULATE (
    MAX ( 'Table'[SortContract] ),
    FILTER (
        'Table',
        'Table'[StartDate] <= 'TF'[date]
            && 'Table'[EndDate] >= 'TF'[date]
            && 'Table'[ID] = EARLIER ( TF[ID] )
    )
)

4.Finally, create the following calculated table to derive the final data structure:

FTable =
UNION (
    SELECTCOLUMNS (
        'TF',
        'TF'[date],
        'TF'[ID],
        "type", "SortContract",
        'TF'[SortContract1]
    ),
    SELECTCOLUMNS ( 'TF', 'TF'[date], 'TF'[ID], "type", "Duty", 'TF'[Duty1] ),
    SELECTCOLUMNS ( 'TF', 'TF'[date], 'TF'[ID], "type", "Company", 'TF'[Company1] ),
    SELECTCOLUMNS ( 'TF', 'TF'[date], 'TF'[ID], "type", "Hours", 'TF'[Hours1] )
)

5.Here's my final result, which I hope meets your requirements.

vlinyulumsft_1-1735018721843.png

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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

 

rajendraongole1
Super User
Super User

Hi @JoseHop - you can create a new table that combines the data from all three tables into a single unified table. This combined table will allow you to show SortContract, Duty, Hours, and Company for each period.

rajendraongole1_0-1732557091765.png

 

 

I am using TAB1,TAB2 and TAB3 , you can replace it as per your model

 

CombinedTable =
UNION(
    SELECTCOLUMNS(
        'TAB1',
        "ID", 'TAB1'[ID ],
        "Date", 'TAB1'[StartDate],
        "Attribute", "SortContract",
        "Value", 'TAB1'[SortContract]
    ),
    SELECTCOLUMNS(
        'TAB1',
        "ID", 'TAB1'[ID ],
        "Date", 'TAB1'[StartDate],
        "Attribute", "Duty",
        "Value", FORMAT('TAB1'[Duty], "General Number")
    ),
    SELECTCOLUMNS(
        'tab2',
        "ID", 'TAB2'[ID ],
        "Date", 'tab2'[StartDateHours],
        "Attribute", "Hours",
        "Value", FORMAT('tab2'[Hours], "General Number")
    ),
    SELECTCOLUMNS(
        'tab3',
        "ID", 'TAB3'[ID ],
        "Date", 'tab3'[StartDateHours],
        "Attribute", "Company",
        "Value", 'tab3'[Company]
    )
)
 
 
Since the tables may have gaps (e.g., SortContract remains the same across periods), use DAX measures to handle "forward fill":
 
LatestValue =
CALCULATE(
    MAX('CombinedTable'[Value]),
    FILTER(
        'CombinedTable',
        'CombinedTable'[Date] <= MAX(Calendar[Date]) &&
        'CombinedTable'[Attribute] = SELECTEDVALUE('CombinedTable'[Attribute])
    )
)
 
rajendraongole1_1-1732557277386.png

 

 

Hope this helps.





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

Proud to be a Super User!





Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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