3

Let's say you have a basic Excel cross-query. You have two lists:

A
B
C

and

X
Y

You cross join them (Cartesian join them), and get the following table:

A - X
A - Y
B - X
B - Y
C - X
C - Y

Now, let's assign values to each of these numbers:

A - X - 1
A - Y - 2
B - X - 3
B - Y - 4
C - X - 5
C - Y - 6

Now, I want to add a new item to the list - Z

My lists are now

A
B
C

and

X
Y
Z

and my cross join is now:

A - X
A - Y
A - Z
B - X
B - Y
B - Z
C - X
C - Y
C - Z

However, here's where the issue comes in. After I've done this, these are my values:

A - X - 1
A - Y - 2
A - Z - 3
B - X - 4
B - Y - 5
B - Z
C - X
C - Y
C - Z - 6

No no no, this is all wrong.

I'm currently working around this by pasting the value over before I refresh the table, then running an index-match from the new table to the old table to populate the data over. But I imagine that there has to be a better way.

How can I get my cross joins to remember their data, and keep them fixed?

Example expected result:

A - X - 1
A - Y - 2
A - Z
B - X - 3
B - Y - 4
B - Z
C - X - 5
C - Y - 6
C - Z

OS: Windows 10 Version: Excel 365

let
    Source = TableA,
    #"Added Custom" = Table.AddColumn(Source, "Lab Name", each LabNames),
    #"Expanded Lab Name" = Table.ExpandTableColumn(#"Added Custom", "Lab Name", {"Lab Abbrv"}, {"Lab Abbrv"})
in
    #"Expanded Lab Name"
7
  • How exactly are you doing the cross join ?
    – harrymc
    Commented Aug 20, 2018 at 19:01
  • With power query. You take the table "Suits", add a custom column, and add the table "Numbers", assuming you've loaded both into the data model. This will create the cross join "Deck of cards"
    – Selkie
    Commented Aug 20, 2018 at 19:19
  • Edit your post to include your queries
    – Olly
    Commented Aug 21, 2018 at 11:56
  • How do "Suits" and "Numbers" relate to your question?
    – harrymc
    Commented Aug 21, 2018 at 15:32
  • @Olly - it's a two item cross join - they don't get much simpler than that.
    – Selkie
    Commented Aug 21, 2018 at 16:05

0

You must log in to answer this question.

Browse other questions tagged .