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
InsightSeeker
Helper III
Helper III

Create a new table and merge data based on specific values.

Hello everyone,

 

I require your assistance in consolidating data from multiple columns into a single table based on specific conditions. Instead of generating a calculated column, I intend to create a new table.

 

I have provided a PBIX sample data file for reference. You can access it  CLICK HERE

 

**Condition 1 (Column1):**

 

For each unique_id:

- Find the first Leg_Num and merge the corresponding From and To values into one column.

- Find the second Leg_Num and merge the corresponding From and To values into one column.

- Find the third Leg_Num and merge the corresponding From and To values into one column.

- Find the fourth Leg_Num and merge the corresponding From and To values into one column.

Continue this process...

 

Use "-" between From and To in the final result.

 

**Condition 2 (Column2):**

 

For each unique_id:

- Find the first Leg_Num and merge the corresponding From_Date and To_Date into one column.

- Find the second Leg_Num and merge the corresponding From_Date and To_Date into one column.

- Find the third Leg_Num and merge the corresponding From_Date and To_Date into one column.

- Find the fourth Leg_Num and merge the corresponding From_Date and To_Date into one column.

Continue this process...

 

Use "|" between From and To in the final result.

 

**Condition 3 (Column3):**

 

For each unique_id:

- Find the first Leg_Num and merge the Category with the second Leg_Num.

Continue this process...

 

Use "-" between From and To in the final result.

 

**Condition 4 (Column4):**

 

For each unique_id:

- Sum all Co2 values.

 

**Condition 5 (Column5):**

 

For each unique_id:

- Sum all KM values.

 

Here is the link to the report Client Here

 

The resulting table should be displayed as follows:

 

unique_idNumber**Condition 1 (Column1):****Condition 2 (Column2):****Condition 3 (Column3):****Condition 4 (Column4):****Condition 5 (Column5):**
10958156073252842KGL-NBO05-Apr-24H31312471
10958286073252847DXB-KWI-DXB04-Apr-24|05-Apr-24K-K690111062
10958796073199119CAI-FCO-CAI12-Apr-24|17-Apr-24Z-Z775272672
10958806073199120CAI-FCO-CAI12-Apr-24|17-Apr-24Z-Z775272672
10958846073256049NBO-KGL03-Apr-24Q46215471
10959326073252871DXB-LHR-DXB29-Apr-24|04-May-24O-O988176842
10959366073252873CAI-DXB-CAI25-Apr-24|06-May-24O-O1073333006

InsightSeeker_0-1724167968259.png

 

 

2 REPLIES 2
Irwan
Super User
Super User

@InsightSeeker 

 

not really clear on what is your requirements.

 

1. what do you mean by first, second, third, fourth leg_num? is it refer to number 1,2,3,4? and what is happens to 5,6,7,8 as you have those values.

Irwan_0-1724212235802.png

 

2. what is result difference between first,second,third,fourth leg_num in Condition 1 and Condition 2? basically it was just copied-pasted.

 

3. in Condition 1, why there are some rows with repeated value?

Irwan_2-1724212627469.png

 

4. how to get Condition 3 result? the picture you shown is not very clear explaining on how to get that value.

 

5. your 'Co2' column does have no value. so how you can get that sum value?

Irwan_1-1724212524450.png

 

Please give a clear explaination on what your result so people here can help you better.

 

Thank you.

Hi @Irwan  -  Please find below my comments:-

 

1. what do you mean by first, second, third, fourth leg_num? is it refer to number 1,2,3,4? and what is happens to 5,6,7,8 as you have those values. Yes, Leg_Num refers to the 1,2,3,4,5,6,7,8 etc... In this oder the from & to coloumns should be joined.

 

2. what is result difference between first,second,third,fourth leg_num in Condition 1 and Condition 2? basically it was just copied-pasted. Condition one is joinging of sectors wheareas Condition 2 is joining of dates.

 

3. in Condition 1, why there are some rows with repeated value? These repeated values in Condition 1 is because it had different unique ID and Number.

 

4. how to get Condition 3 result? the picture you shown is not very clear explaining on how to get that value. Condition 3 is joining of the category column.

 

5. your 'Co2' column does have no value. so how you can get that sum value? Some the cells will not have any value, in this case 0 is to be returned.

 

Require :- Each unique ID (or multiple unique IDs) will have multiple "From" and "To" data points. I need to join this data in ascending order based on the `Leg_num`. Once all the data is joined, I need to create a new table that displays each unique ID & Number only once, along with all the associated conditions in separate columns.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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