Power bi,在功能方面领先于零问题

时间:2018-12-10 21:12:26

标签: powerbi powerquery

我具有此功能,如果许可证号有效,它可以检索数据。例如:10002212。该功能不接受前导零为08001366的有效许可证号,并且出错。如何使该功能接受领先的ZERO颁发的有效许可证?。

谢谢。

(LicenceNumber) =>
let
Source = 
Web.Page(Web.Contents("http://mbsweblist.fsco.gov.on.ca/ShowLicence.aspx?M" 
& Number.ToText(LicenceNumber) & "~")),
WebData = Source{1}[Data],
#"Extracted Text Before Delimiter" = Table.TransformColumns(WebData, 
{{"Column1", each Text.BeforeDelimiter(_, ":"), type text}}),
#"Removed Top Rows" = Table.Skip(#"Extracted Text Before Delimiter",1),
#"Transposed Table" = Table.Transpose(#"Removed Top Rows"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", 
[PromoteAllScalars=true])
in
#"Promoted Headers"

1 个答案:

答案 0 :(得分:1)

如果您知道许可证号应始终为8个字符长,则可以使用Text.PadStart添加前导零:

(LicenceNumber) =>
let
    LicenceText = Text.PadStart(Number.ToText(LicenceNumber,8,"0")
    Source = Web.Page(Web.Contents("http://mbsweblist.fsco.gov.on.ca/ShowLicence.aspx?M"& LicenceText & "~")),
    WebData = Source{1}[Data],
    #"Extracted Text Before Delimiter" = Table.TransformColumns(WebData, {{"Column1", each Text.BeforeDelimiter(_, ":"), type text}}),
    #"Removed Top Rows" = Table.Skip(#"Extracted Text Before Delimiter",1),
    #"Transposed Table" = Table.Transpose(#"Removed Top Rows"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true])
in
    #"Promoted Headers"