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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
MyOx
Frequent Visitor

Divide row A by row B for all column

Hello,

 

I trying to build an attrition table in power query (not Dax).

I have two table containing all my topics: one with the amount the remaining items (A), one with the maximum item (B).

I want, for each column to do A/B.

Here's an exemple:

TopicRowDébutM1M2M3M4M5
Topic 1A100806040200
Topic 2A1008570554025
        
TopicRowDébutM1M2M3M4M5
Topic 1B10010090858075
Topic 2B10010080604020

 

The final table should look like this

TopicRow M1M2M3M4M5
Topic 1Final Result (A/B) 80%67%47%25%0%
Topic 2Final Result (A/B) 85%88%92%100%125%

 

Concidering that I have a thousand rows (Topic 1 to Topic 1000) and a thousand column (M1 to M1000), how could I do that?

 

Note: So far I found that if both Table are merge, I can do this = Table.ReplaceValue(#"Added Index", each [M2], each [M2]/#"Added Index"[M2]{[Index] -1}, Replacer.ReplaceValue,{"M2"}) to get my answer for one column. Not enough but it'

1 ACCEPTED SOLUTION
AlienSx
Super User
Super User

Hello, @MyOx 

let
    tbl1 = your_table_one,
    tbl2 = your_table_two,
    topics = List.Buffer(tbl1[Topic]),
    names = List.Buffer(List.Skip(Table.ColumnNames(tbl1), 3)),
    rows_one = List.Buffer(Table.ToRows(Table.SelectColumns(tbl1, names))),
    rows_two = List.Buffer(Table.ToRows(Table.SelectColumns(tbl2, names))),
    positions = List.Positions(rows_one), 
    tx = 
        List.Transform(
            positions, 
            (x) => 
                [a = List.Zip({rows_one{x}, rows_two{x}}),
                b = {topics{x}} & List.Transform(a, each Value.Divide(_{0}, _{1}))][b]
        ),
    fnl = Table.FromRows(tx, {"Topic"} & names)
in
    fnl

View solution in original post

1 REPLY 1
AlienSx
Super User
Super User

Hello, @MyOx 

let
    tbl1 = your_table_one,
    tbl2 = your_table_two,
    topics = List.Buffer(tbl1[Topic]),
    names = List.Buffer(List.Skip(Table.ColumnNames(tbl1), 3)),
    rows_one = List.Buffer(Table.ToRows(Table.SelectColumns(tbl1, names))),
    rows_two = List.Buffer(Table.ToRows(Table.SelectColumns(tbl2, names))),
    positions = List.Positions(rows_one), 
    tx = 
        List.Transform(
            positions, 
            (x) => 
                [a = List.Zip({rows_one{x}, rows_two{x}}),
                b = {topics{x}} & List.Transform(a, each Value.Divide(_{0}, _{1}))][b]
        ),
    fnl = Table.FromRows(tx, {"Topic"} & names)
in
    fnl

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors