Forum Discussion
agd50
3 years agoHelper V
Expanding/Duplicating Rows with the same values?
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 possib...
- 3 years ago
= 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 - 3 years ago
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) })
Ahmedx
3 years agoSuper User
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)
})agd50
3 years agoHelper V
(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.