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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
TommyMossberg
Helper I
Helper I

Join/Pivot two tables with no relations?

Hi

 

I have two tables I want to join but I don't have any connections between them.

 

One of the tables is a date table looks something like this

Start of weekTarget working hours
2021-06-2132
2021-06-2840
2021-07-0540
2021-07-1240
2021-07-1940
2021-07-2640
2021-08-0240

 

And the other is a list of employees.

Anna
Stina
Farah
Johan
Kevin

 

I would like to create a table with all the dates in Col A and the names in the other columns and the Target value populated into every employees column.

Start of weekAnnaStinaFarahJohanKevin
2021-06-213232323232
2021-06-284040404040
2021-07-054040404040
2021-07-124040404040
2021-07-194040404040
2021-07-264040404040
2021-08-024040404040
..................

 

How do I make this happen in Power Query?

 

Next step is to supstract actual planned and/or chargeable workhours from target to calculate the theoretical cost of non-chargeable hours.

 

I have about 250 employees and the date-table is calculated the next ten years.

The Emplyee-list updates every month so I don't want to manualy code it.

 

Thanks in advance!

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Add the employee list as a custom column, expand that column, then pivot on that column.

let
    Source = <Date Table Sourcce>,
    #"Added Custom" = Table.AddColumn(Source, "Custom", each Employees[Employee]),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Pivoted Column" = Table.Pivot(#"Expanded Custom", List.Distinct(#"Expanded Custom"[Custom]), "Custom", "Target working hours")
in
    #"Pivoted Column"

 

In the above, I'm assuming Employees is a separately loaded query with a column named [Employee] that is the list of names.

View solution in original post

5 REPLIES 5
CNENFRNL
Community Champion
Community Champion

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ1MNM1MlTSUTI2UorVQRKzAIqZGCCJmesamGKKGRphEbPEFDMyQxez0DWA6Y0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Start of week" = _t, #"Target working hours" = _t]),
    Emp = {"Anna","Stina","Farah","Johan","Kevin"},
    Custom1 = let n=List.Count(Emp) in Table.TransformColumns(Source, {"Target working hours", each Table.FromRows({List.Repeat({_},n)}, Emp)}),
    #"Expanded Target working hours" = Table.ExpandTableColumn(Custom1, "Target working hours", Emp, Emp)
in
    #"Expanded Target working hours"

Screenshot 2021-06-14 221411.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

If you're constructing a table, you could also use Table.FromColumns.

 

let
    Source = DateTable,
    Start = Source[Start of week],
    Target = Source[Target working hours],
    Emp = Employees[Employee],
    n = List.Count(Emp)
in
    Table.FromColumns({Start} & List.Repeat({Target}, n), {"Start of week"} & Emp)
Anonymous
Not applicable

@AlexisOlson Slick solution, sir!

AlexisOlson
Super User
Super User

Add the employee list as a custom column, expand that column, then pivot on that column.

let
    Source = <Date Table Sourcce>,
    #"Added Custom" = Table.AddColumn(Source, "Custom", each Employees[Employee]),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Pivoted Column" = Table.Pivot(#"Expanded Custom", List.Distinct(#"Expanded Custom"[Custom]), "Custom", "Target working hours")
in
    #"Pivoted Column"

 

In the above, I'm assuming Employees is a separately loaded query with a column named [Employee] that is the list of names.

Super! This did the trick!

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 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.

Top Solution Authors
Top Kudoed Authors