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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
tvanover
Helper II
Helper II

replace value in a table (based on value of other row with same foreign key)

Hello everyone,

 

I have two tables linked with a common key

 

orderlines table:

OrdernumberOrderline
1191orderline_guid1
1191orderline_guid2
1191orderline_guid3
1191orderline_guid4

 

deliverylines table:

RowOrderlineTransportcoWeight
1orderline_guid1GLS7
2orderline_guid2GLS8
3orderline_guid2 4
4orderline_guid3 12
5orderline_guid4 2

 

the link between the tables is 

[deliverylines].orderline many-to-one -> [orderlines].orderline

 

Now, I would like to modify the contents of the [deliverylines].transportco column in such a way that rows 3, 4 and 5 also contain the value GLS, based on the fact that both 5 rows are linked to the same Ordernumber (via the orderline key), and because at least one of these rows already has a value GLS for that column.

 

That's because I need to show the sum of the weights of all deliverylines linked to  the same ordernumber, and have the value GLS shown in the visual as well.

 

How can I achieve this in the power query editor? Either by directly manipulating the transportco column, or by creating another column with the desired values?

 

Thanks,

 

 

1 ACCEPTED SOLUTION
tvanover
Helper II
Helper II

Following up on my own previous post, I solved my problem by:

- merging all related queries into 1 big table

- grouping in this table using a combination of sum and max, see screenshot:

 

groupby.PNG

View solution in original post

5 REPLIES 5
v-robertq-msft
Community Support
Community Support

Hi, @tvanover 

Glad to see you have solved your problem, would you like to mark your solution reply as a solution so that others can learn from your solution?

Thanks in advance!

 

Best Regards,

Community Support Team _Robert Qin

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

tvanover
Helper II
Helper II

Following up on my own previous post, I solved my problem by:

- merging all related queries into 1 big table

- grouping in this table using a combination of sum and max, see screenshot:

 

groupby.PNG

tvanover
Helper II
Helper II

Hello,

 

Thanks for the excellen tutorial, I've followed these instructions on my pbix file, and it works.

But....

Ordernumbers are updated in realtime, and the report should also be updated automatically.

So if a new order is finished, I would want to see that same calculation happen for that ordernumber, without me having to add each time a new order to that conditionnal column.

 

So while your example works, it's static and I need something that does the samething automatically for each now ordernumber that pops up in my source table.

 

Do you see any solution to that as well?

 

appreciate all the effort!

tom

Hello,

I've been thinking this over, and I'm thinking of another approach:

 

Please see this visual:

Knipsel.PNG

What I want to see is this:

 

1191 GLS 40.82 3/12/2020 16:07:21 (the datestamp always correspons to the order number)

 

Perhaps it's possible somehow to do a sum(gewicht) based only the field order, and display MAX(Transport) at the same time? 

I tried it with a measure, but it doesn't seem to take account of all the relations between the tables, because the output is now totally garbled.

 

You can download my test file here, if you want to have another go at it (or someone else) ?

 

https://www.dropbox.com/s/l4io6cetyl1nb3p/transport-problem.pbix?dl=0

 

v-robertq-msft
Community Support
Community Support

Hi, @tvanover 

According to your description, you want to make each column display “GLS” when [Ordernumber] is 1911, you can follow my steps:

  1. Go to power query editor, select ‘deliverylines’ table, merge query like this:

v-robertq-msft_0-1607048177927.png

 

  1. Expand the table like this:

屏幕截图 2020-12-04 101650.png

  1. Add a conditional column, like this:

v-robertq-msft_2-1607048177938.png

 

If you want to add other [Transportco] for other Ordernumbers(like 1192, 1193), you can click add clause to add other coditions.

And you can get what you want, like this:

屏幕截图 2020-12-04 101657.png

You can download my test pbix file here

 

Best Regards,

Community Support Team _Robert Qin

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.