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
Anonymous
Not applicable

Adding a column using a list of distinct values from another tables column

Hi,

 

I have spent some time googling this but maybe not asking the question correctly to find the information....

 

Anyway what I am trying to do is as followings 

 

TABLE A 

From this table create a list from a Date column that containts all the unique dates.

 

Table B

In this Table I want to add a new column that containts the list generated from Table A

Col ACol BNEW COL  
Fact 1Fact 1Table A - List
Fact 2Fact 2Table A - List

 

Once I have this I can then expand the list... so I end up with a table with rows that repeats Fact 2 for all the dates and the same for Fact 2 

 

Col ACol BNEW COL
FACT 1FACT 101/01/2020
FACT 1FACT 108/01/2020
FACT 2FACT 201/01/2020
FACT 2FACT 208/01/2020

 

 

I have unsucessfully tried a number of approaches that keep coming up with errors like

Timaru_Golf_0-1593611703554.png

 

So the question is does anyone know how to do this?

 

Thanks in advance

 

1 ACCEPTED SOLUTION

Writing code in the advanced editor is an option but it wouldn't be my first thought.

Use the 'Add Column' tab in the editor.

 

I'm not going to write the line for you as you're nearly there.

View solution in original post

6 REPLIES 6
parry2k
Super User
Super User

@Anonymous use CROSSJOIN DAX function to get the expected result.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Sorry forgot to mention this is within M code

Writing code in the advanced editor is an option but it wouldn't be my first thought.

Use the 'Add Column' tab in the editor.

 

I'm not going to write the line for you as you're nearly there.

Anonymous
Not applicable

Thanks I was over thinking it - works a treat.

 

 // Create Unique DATE column
    #"Removed Other Columns1" = Table.SelectColumns(#"Remove KEY",{"Report Date"}),
    #"Report Date" = Table.Distinct(#"Removed Other Columns1"),

// Create Fact table expanded by Dates
    #"Removed Other Columns" = Table.SelectColumns(#"Remove KEY",{"COUNTRY", "CustomerName", "CustomerNumber", "Class"}),
    #"Removed Duplicates1" = Table.Distinct(#"Removed Other Columns"),
    #"Added Custom1" = Table.AddColumn(#"Removed Duplicates1", "Custom", each #"Report Date"),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom1", "Custom", {"Report Date"}, {"Report Date"}),
HotChilli
Super User
Super User

Don't know what TableA (does it already have unique dates?)  looks like but  this should work

 

In Table B, Add a custom column with the code 

TableA[thedatecolumn]

 

Anonymous
Not applicable

Yes Table A is just a single column of unique dates.

 

Timaru_Golf_0-1593613630947.png

 

So it how I add this as a new column - my code looks like this -- having a problem with what I would put in the last line 

 

 // Create Unique DATE column
    #"Removed Other Columns1" = Table.SelectColumns(#"Remove KEY",{"Report Date"}),
    #"Report Date" = Table.Distinct(#"Removed Other Columns1"),

// Create Fact table expanded by Dates
    #"Removed Other Columns" = Table.SelectColumns(#"Remove KEY",{"COUNTRY", "CustomerName", "CustomerNumber", "Class"}),
    #"Removed Duplicates1" = Table.Distinct(#"Removed Other Columns"),
    #"Added Custom" = Table.AddColumn(XXXXXXX),

 

Thanks

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.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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