Forum Discussion
Expand columns doesn't work after Merging queries
- 6 years ago
This might be a long shot, but sometimes the issue is simpler than it looks.
Does any of the columns that you are trying to join have trailing spaces?
Try to trim the columns or transform them using Text.Start and check if this resolves the issue that you're having.
Hello florentb
OMG... i completly got it wrong... LOL.. too many thoughts.
Could you try this code if it works?
let
Source = Sql.Database("DLSC-d-PRD-RO", "MSDLSD"),
dbo_PLM_PRODUCT_SAMPLE = Source{[Schema="dbo",Item="PLM_PRODUCT_SAMPLE"]}[Data],
#"Lignes filtrées" = Table.SelectRows(dbo_PLM_PRODUCT_SAMPLE, each ([SampleType] = "Affectation couleur ") and ([StatutProduction] = "Affecté ")),
#"Personnalisée ajoutée" = Table.AddColumn(#"Lignes filtrées", "GoProd", each if [FlagGoProdProto]="true" then 1 else 0),
#"Type modifié" = Table.TransformColumnTypes(#"Personnalisée ajoutée",{{"GoProd", Int64.Type}, {"ERPCode", type text}}),
#"Personnalisée ajoutée1" = Table.AddColumn(#"Type modifié", "Log", each if [FirstExportOkDate]=null then 0 else 1),
#"Type modifié1" = Table.TransformColumnTypes(#"Personnalisée ajoutée1",{{"Log", Int64.Type}}),
#"Personnalisée ajoutée2" = Table.AddColumn(#"Type modifié1", "Site", each Text.AfterDelimiter([Fournisseur],"-")),
#"Personnalisée ajoutée3" = Table.AddColumn(#"Personnalisée ajoutée2", "key PDM-SITE", each Text.Start([CodePDM],8) & "-" & Text.Start([Fournisseur],4)),
#"Valeur remplacée" = Table.ReplaceValue(#"Personnalisée ajoutée3"," ","",Replacer.ReplaceText,{"CodePDM"}),
#"Requêtes fusionnées" = Table.NestedJoin(#"Valeur remplacée", {"CodePDM"}, #"PLM_STYLE_DETAIL (2)", {"StyleCode"}, "PLM_STYLE_DETAIL (2)", JoinKind.LeftOuter),
#"PLM_STYLE_DETAIL (2) développé" = Table.ExpandTableColumn(#"Requêtes fusionnées", "PLM_STYLE_DETAIL (2)", {"Siteleader"}, {"Siteleader"}),
#"Personnalisée ajoutée4" = Table.AddColumn(#"PLM_STYLE_DETAIL (2) développé", "Leader?", each if Text.Start([Fournisseur],4)=Text.Start([Siteleader],4) then true else null)
in
#"Personnalisée ajoutée4"
All the best
Jimmy
Hello,
Jimmy801 wrote:Hello florentb
OMG... i completly got it wrong... LOL.. too many thoughts.
Could you try this code if it works?
let
Source = Sql.Database("DLSC-d-PRD-RO", "MSDLSD"),
dbo_PLM_PRODUCT_SAMPLE = Source{[Schema="dbo",Item="PLM_PRODUCT_SAMPLE"]}[Data],
#"Lignes filtrées" = Table.SelectRows(dbo_PLM_PRODUCT_SAMPLE, each ([SampleType] = "Affectation couleur ") and ([StatutProduction] = "Affecté ")),
#"Personnalisée ajoutée" = Table.AddColumn(#"Lignes filtrées", "GoProd", each if [FlagGoProdProto]="true" then 1 else 0),
#"Type modifié" = Table.TransformColumnTypes(#"Personnalisée ajoutée",{{"GoProd", Int64.Type}, {"ERPCode", type text}}),
#"Personnalisée ajoutée1" = Table.AddColumn(#"Type modifié", "Log", each if [FirstExportOkDate]=null then 0 else 1),
#"Type modifié1" = Table.TransformColumnTypes(#"Personnalisée ajoutée1",{{"Log", Int64.Type}}),
#"Personnalisée ajoutée2" = Table.AddColumn(#"Type modifié1", "Site", each Text.AfterDelimiter([Fournisseur],"-")),
#"Personnalisée ajoutée3" = Table.AddColumn(#"Personnalisée ajoutée2", "key PDM-SITE", each Text.Start([CodePDM],8) & "-" & Text.Start([Fournisseur],4)),
#"Valeur remplacée" = Table.ReplaceValue(#"Personnalisée ajoutée3"," ","",Replacer.ReplaceText,{"CodePDM"}),
#"Requêtes fusionnées" = Table.NestedJoin(#"Valeur remplacée", {"CodePDM"}, #"PLM_STYLE_DETAIL (2)", {"StyleCode"}, "PLM_STYLE_DETAIL (2)", JoinKind.LeftOuter),
#"PLM_STYLE_DETAIL (2) développé" = Table.ExpandTableColumn(#"Requêtes fusionnées", "PLM_STYLE_DETAIL (2)", {"Siteleader"}, {"Siteleader"}),
#"Personnalisée ajoutée4" = Table.AddColumn(#"PLM_STYLE_DETAIL (2) développé", "Leader?", each if Text.Start([Fournisseur],4)=Text.Start([Siteleader],4) then true else null)
in
#"Personnalisée ajoutée4"
All the best
Jimmy
Hahaha no problem !
I tried it and it doesn't work ....
TheDataMustFlow wrote:This might be a long shot, but sometimes the issue is simpler than it looks.
Does any of the columns that you are trying to join have trailing spaces?
Try to trim the columns or transform them using Text.Start and check if this resolves the issue that you're having.
It wooooorked !!! 🎉
The devil is really in the detail, I just replaced all " " by "" and now it's ok.
Many thanks to all of you !