Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
I want to be able to duplicate a row only if the value is 2, 3 or more - so that it will duplicate it to this value (ie 2 = 2 rows). The rest of the row includes workers details. Is this possible?
(sensitive data)
Solved! Go to Solution.
= Table.TransformColumns(
from, { "Count", (x)=>
List.Transform(List.Repeat( {x},x),(y)=> 1)
}
)
Yes, you can do it in power query For it
watch my video here
https://1drv.ms/v/s!AiUZ0Ws7G26RhkuysN5T04JZpItg?e=UErUKu
I'm sorry, you can shorten the M code like this
= Table.TransformColumns(
from, { "Count", (x)=>
List.Transform(List.Repeat( {x},x),(y)=> 1)
}
)to
= Table.TransformColumns(
from, { "Count", (x)=> List.Repeat( {"1"},x)
})
I'm sorry, you can shorten the M code like this
= Table.TransformColumns(
from, { "Count", (x)=>
List.Transform(List.Repeat( {x},x),(y)=> 1)
}
)to
= Table.TransformColumns(
from, { "Count", (x)=> List.Repeat( {"1"},x)
})
(Before)

(After)
How would the formula change for any additional columns such as the imaginary one I have added? The logic is if 0 then = 0 (I got Null), IF 1 = 1, Else IF greater than 1 (2 or more) than duplicate the entire row.
= Table.TransformColumns(
from, { "Count", (x)=>
List.Transform(List.Repeat( {x},x),(y)=> 1)
}
)
Yes, you can do it in power query For it
watch my video here
https://1drv.ms/v/s!AiUZ0Ws7G26RhkuysN5T04JZpItg?e=UErUKu
You are a champion, I wish i had your brain. I assume that this is M Code?
Well done.

This is effectively what I want to do - (1st is before - 2nd screenshot is after) - Obviously just much more data.
this can be done in power query
make a small example so we can help you
I have created a pbix file but you can't upload that here, would an excel sheet be better?
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 22 | |
| 22 | |
| 18 | |
| 16 | |
| 13 |
| User | Count |
|---|---|
| 63 | |
| 42 | |
| 40 | |
| 40 | |
| 38 |