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.
Hi All,
What the heck am I doing wrong? I bet it is something tiny, but because I don't know the M Language, I'm missing it. I need to remove leading zeros from contract numbers prior to creating a Key. I cannot figure out the proper exact command.
I am doing this:
= Text.TrimStart([Contract_Number], "0")
I receive: "Expression. Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?"
Any ideas as to what I am missing?
Thanks!
Solved! Go to Solution.
Hi @Shelley,
Please try this code (I only changed the step Removed Columns to dbo_RepairTransaction in order to take into account the previous step:
let Source = Sql.Database("CSMDataService.cloudapp.net", "CSM_Master"), dbo_RepairTransaction = Source{[Schema="dbo",Item="RepairTransaction"]}[Data], #"Added Custom" = Table.AddColumn(dbo_RepairTransaction, "Custom", each if Text.Start([Contract_Number],1)="0" then Text.TrimStart([Contract_Number],"0") else [Contract_Number]), #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Contract_Number"}), #"Renamed Columns1" = Table.RenameColumns(#"Removed Columns",{{"Custom", "Contract_Number"}}), #"Inserted Merged Column" = Table.AddColumn(dbo_RepairTransaction, "Key", each Text.Combine({[End_User_Key], [Contract_Number]}, "="), type text), #"Renamed Columns" = Table.RenameColumns(#"Inserted Merged Column",{{"Key", "%BPIDContractKey"}}) in #"Renamed Columns"
Let us know.
Ninter
@Interkoubess Thanks for the reply. I finally got it to work, but another step (second to last line) had to be changed to point to the previous step. I couldn't have done it without you. Thanks!
let
Source = Sql.Database("DataService.cloudapp.net", "Master"),
dbo_RepairTransaction = Source{[Schema="dbo",Item="RepairTransaction"]}[Data],
#"Added Custom" = Table.AddColumn(dbo_RepairTransaction, "Custom", each if Text.Start([Contract_Number],1)="0" then Text.TrimStart([Contract_Number],"0") else [Contract_Number]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Contract_Number"}),
#"Renamed Columns1" = Table.RenameColumns(#"Removed Columns",{{"Custom", "Contract_Number"}}),
#"Inserted Merged Column" = Table.AddColumn(#"Renamed Columns1", "Key", each Text.Combine({[End_User_Key], [Contract_Number]}, "="), type text),
#"Renamed Columns" = Table.RenameColumns(#"Inserted Merged Column",{{"Key", "%BPIDContractKey"}})
in
#"Renamed Columns"
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
97 | |
86 | |
70 | |
62 |
User | Count |
---|---|
151 | |
120 | |
103 | |
87 | |
68 |