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

Split rows in news rows with a new dimension depending from values in another table

Hello everybody,

 

I have a table with values (revenue, margin, ...) and want to split the rows depending on the values (share%) of another table. Should I build a new table, or split the rows in the same table or working with measures? I have no idea and appreciate a lot any suggestions. 

 

Thanks a lot

 

Steve


SplitRowsWithShare.jpg

2 REPLIES 2
gehe_muc
Frequent Visitor

Thank you, I will try it the next day, though I don't understand this concept 😉 will give feedback!

wdx223_Daniel
Super User
Super User

if you did not mind the floating difference, then try this code

=#table({"Month","City","Revenue","Margin"},List.TransformMany(Table.ToRows(Table1),each Table.ToRows(Table2),(x,y)=>{x{0},y{0},x{1}*y{1},x{2}*y{1}}))

otherwise, try this

=let a=Table.ToRows(Table2),b=List.Count(a)-1 in #table({"Month","City","Revenue","Margin"},List.TransformMany(Table.ToRows(Table1),each List.Accumulate(List.Positions(a),{{},_{1},_{2}},(x,y)=>if y=b then {x{0}&{{_{0},a{y}{0},x{1},x{2}}}} else {x{0}&{{_{0},a{y}{0},_{1}*a{y}{1},_{2}*a{y}{1}}},x{1}-_{1}*a{y}{1},x{2}-_{2}*a{y}{1}}),(x,y)=>y{0}))

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.

Top Solution Authors
Top Kudoed Authors