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

Dupliquer lignes en fonction d'un nombre

Bonjour la communauté !

Je suis sûr qu'il a une solution à mon probleme mais je ne trouve pas.

Dans mon exemple ci joint (Tableau 1), j'ai un tableau dans lequel toutes les infos sont identiques.

Je voudrait dupliquer les lignes pas le nombre de la colonne Quantity (Tableau 2)

Alecuyer75_1-1632485604802.png

 

Alecuyer75_2-1632485693370.png

 

D'avance merci pour votre aide 🙂

 

2 ACCEPTED SOLUTIONS
v-yingjl
Community Support
Community Support

Hi @Alecuyer75 ,

Mlawali is correct, the key query is to use Table.Repeat(), unpivot column could not be necessary in this issue.

    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Table.Repeat(Table.FromRecords({[Quantity = 1]}),[Quantity])),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Quantity"}, {"Custom.Quantity"}),

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

AlexandreM
Regular Visitor

Bonjour,
Ajoute une Colonne personnalisé
Colle ce code dedans.
List.Repeat({""}, [Quantity])
ça ajoute une colonne liste.
Clique ensuite sur l'icone suivante dans l'entete de cette nouvelle colonne AlexandreM_0-1696353148727.png

 

View solution in original post

7 REPLIES 7
AlexandreM
Regular Visitor

Bonjour,
Ajoute une Colonne personnalisé
Colle ce code dedans.
List.Repeat({""}, [Quantity])
ça ajoute une colonne liste.
Clique ensuite sur l'icone suivante dans l'entete de cette nouvelle colonne AlexandreM_0-1696353148727.png

 

Petit oubli de ma part, lorsque tu clique sur l'icone il faut choisir "Développer sur de nouvelles lignes".
En vidéo ici.
https://www.youtube.com/watch?v=6NAQf9b5J14

 

v-yingjl
Community Support
Community Support

Hi @Alecuyer75 ,

Mlawali is correct, the key query is to use Table.Repeat(), unpivot column could not be necessary in this issue.

    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Table.Repeat(Table.FromRecords({[Quantity = 1]}),[Quantity])),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Quantity"}, {"Custom.Quantity"}),

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

hello, im a beginner can you tell me where to write this code ? is it creating a new table for the result ?

Bonjour Eyaa,

Ce bout de code est a coller dans Power Query / Editeur avancé

Mlawali
Frequent Visitor

Bonjour,

Essayez le code suivant:

#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Date Trans", "Trans Num", "Libelle Article", "Unit Price"}, "Attribute", "Value"),
#"Added Custom" = Table.AddColumn(#"Unpivoted Other Columns", "Custom", each Table.Repeat(Table.FromRecords({[Quantity=1]}),[Value])),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Quantity"}, {"Quantity"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"Quantity", Int64.Type}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Attribute", "Value"})

Capture.JPG

 

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