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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
albatross19
Frequent Visitor

Assign a value to each row in a table from list

Currently I have a table with customers and their orders to which I need to assign a fulfillment center (list). I need to assign a fulfillment center based on row position. I have a total of 3 fulfillment centers.

 

For example, customer 1 or row 1 gets assign fullfillment center 1. Row 2 gets assign fulfillment center 2, then row 3 gets assign fulfillment center 3. Then I need to restart the loop by assigning row 4 to fulfillment center 1.

 

See example below:

Fulfillment Center
Chicago
Seattle
Boston 

 

IndexCustomerOrdersFulfillment Center
1Mike1Chicago
2Alicia3Seattle
3Steven1Boston
4Maria4Chicago
5Louie2Seattle

 

I am open to solve this problem either by using PowerQuery or DAX (calculated column)

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@albatross19 , Add an index column in tables 1  start with 0  - power query

 

 

then create a new column in table 2  - power query

new index = Number.Mod([Index], 3)

 

Then merge the tables using index and new index in power query

Merge Tables (Power Query) : https://www.youtube.com/watch?v=zNrmbagO0Oo&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=16

 

 


merge: https://radacad.com/append-vs-merge-in-power-bi-and-power-query

View solution in original post

4 REPLIES 4
albatross19
Frequent Visitor

Thank you!

MahyarTF
Memorable Member
Memorable Member

Hi,

If we consider the first Table as a Sheet11 and next one as a Sheet9 :

- Create an Index column for each table :

MahyarTF_0-1658204567070.png

 

- In the Sheet9 (Customer) table, Create a Custom Column as a below statement :

= Table.AddColumn(#"Added Custom1", "link Col", each if Table.RowCount(Sheet11) >= [Index] then [Index] else if Number.Mod([Index], Table.RowCount(Sheet11) ) = 0 then 3 else Number.Mod([Index], Table.RowCount(Sheet11) ))

Now if create a relationship between two tables based on the "Index" column and "Link Col" :

MahyarTF_2-1658204809091.png

You could have the below visual :

MahyarTF_3-1658204901287.png

Hop it will be useful

Mahyartf

Thank you!

amitchandak
Super User
Super User

@albatross19 , Add an index column in tables 1  start with 0  - power query

 

 

then create a new column in table 2  - power query

new index = Number.Mod([Index], 3)

 

Then merge the tables using index and new index in power query

Merge Tables (Power Query) : https://www.youtube.com/watch?v=zNrmbagO0Oo&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=16

 

 


merge: https://radacad.com/append-vs-merge-in-power-bi-and-power-query

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.