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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
LoryMenCR
Helper I
Helper I

Spread value of a row in other rows

Dear All,

i have the following table:

CodeDescValue
3Code 3 - Desc 1100
3Code 3 - Desc 250
5Code 5 - Desc 1200
7Code 7 - Desc 1300
7Code 7 - Desc 2600
9Code 9 - Desc 1800
100Code 100 - Desc 11000

 

I also have  a table which defines my codes:

CodeCode Name
3Name 3
5Name 5
7Name 7
9Name 9
100Name 100

 

 

What i need is to spread the value of Code 100 throughout all the other codes proportionally.
Result would be the following:

 

CodeDescValue
3Code 3 - Desc 1100
3Code 3 - Desc 250
3100250
5Code 5 - Desc 1200
5100250
7Code 7 - Desc 1300
7Code 7 - Desc 2600
7100250
9Code 9 - Desc 1800
9100250
100Code 100 - Desc 11000

 

Any idea?
Thanks a lot

7 REPLIES 7
nandic
Super User
Super User

Hi @LoryMenCR ,
This makes it harder a little bit, but attached solution.
I am not Power Query expert, if there is an easier solution, it would be perfect!

Steps:
Based on main table, create additional two tables which result is 1 value.
1) 1st table: distinct count of codes (except 100)
2) 2nd table: value of code 100

When we have this, we duplicate main table (or just copy M script to prevent creating duplicate tables)
1) add new column: just reference 1st table from above and expand it
2) same thing for 2nd table
3) create 3rd column where you divide 1st expanded column with 2nd expanded column
Rename all columns to be same as main table.
And then just create append table.

Cheers,
Nemanja Andic

nandic_0-1726482668151.png

 

Dear @nandic I appreciate your support and thank you a lot, but i tried and won't work.
I might open a new discussion trying to put the question in a more detailed way.

Have a nice day

Hi @LoryMenCR 

 

Have you solved your problem? If so, can you share your solution here and mark the correct answer as a standard answer to help other members find it faster? Thank you very much for your kind cooperation!

 

Best Regards

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

nandic
Super User
Super User

Hi @LoryMenCR , @RYRY sent great example of how it should be applied. 

The second table is dynamic as it is based on the main table. Just remove duplicates based on column Code and remove row for Code 100.
After that you add 2 new columns:
1. Desc = "100". It should be formatted as text
2. Value = 250. This one is the only static part of the solution.
Append will combine these two tables and it will return correct data.

If column Value should not be static (250), but have some kind of dynamic formula, just send requirement and we will try to find the solution.

Cheers,
Nemanja Andic

Dear @nandic , thanks a lot for your contribution. 

Actually 250 should not be static as it is the value of Desc = "100" divided by the number of distinct codes (except for code "100") which vary day by day.

I really like the approach though (don't know if this could be reach through a measure...)

 

ryan_mayu
Super User
Super User

pls see if this is what you want

1. create a new table based on the second table

12.PNG

 

then append the new table to the first tabel

11.png13.PNG

 

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Dear @ryan_mayu , the execution would be great but I need an automatic input of values, not a manual one.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.