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
nzaccountant
Frequent Visitor

M Code to extract IO number

hi there

I have a list of Machinery Items with Internal order (IO) Numbers. 

I then have a list of transactions with the IO number contained in it. 

 

I would like to write some sort of M code which attempts to do the following:

1) Extracts the IO numbers from the machinery list

2) If one of these IO numbers is found in the transaction list, add the IO as a custom column

3) If no IO is found, return BLANK. 

 

Sample Machinary list:

IO NumberMachinary Name
T453Tractor 1
Y654Sprayer 1
F435Tractor 2

 

Sample transaction list

 

Transaction DetailIO Number?
Service for T453 
F435 Service 
Work of Y654 

 

The goal is to create a list of machinary items that has a relationship with the transaction table via a new column called IO number. 

Thanks

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @nzaccountant ,

Here are the steps you can follow:

1. Select add column - index column - from 1 in the power query to add indexes for both tables.

vyangliumsft_0-1624868948094.png

2. Select Home-Merge Queries-Merge Queries, merge the two tables using left Outer according to [Index],

vyangliumsft_1-1624868948098.png

3. Select Add column – Custom column

vyangliumsft_2-1624868948101.png

4. Result:

vyangliumsft_3-1624868948113.png

 

Best Regards,

Liu Yang

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

View solution in original post

1 REPLY 1
v-yangliu-msft
Community Support
Community Support

Hi  @nzaccountant ,

Here are the steps you can follow:

1. Select add column - index column - from 1 in the power query to add indexes for both tables.

vyangliumsft_0-1624868948094.png

2. Select Home-Merge Queries-Merge Queries, merge the two tables using left Outer according to [Index],

vyangliumsft_1-1624868948098.png

3. Select Add column – Custom column

vyangliumsft_2-1624868948101.png

4. Result:

vyangliumsft_3-1624868948113.png

 

Best Regards,

Liu Yang

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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