Token Comma expected error - Trying to Select Data Source based on True/False
Results 1 to 4 of 4

Thread: Token Comma expected error - Trying to Select Data Source based on True/False

  1. #1
    New Member
    Join Date
    Jun 2019
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Token Comma expected error - Trying to Select Data Source based on True/False

    Hi – new to the forum and (fairly) new to Power Query.
    I have managed to get the basics down (I think), and just started trying to tinker with the Advanced options.
    What I have been trying to do is download a file, based on whether or not a value on aseparate table is True/False, if it is true it downloads one way, if falseanother file.
    Like I said, I’m still trying to get my head around the advanced editor and how the codeis structured, but from what I understand you reference the previous variable andthe actual order is less important.
    Anyway, it got me here:


    let
    Bool = fnGetParameter("CSV"),

    Sourcexl =Excel.Workbook(File.Contents("L:\Accounts Payable\Month End-AP\Month EndReports\2019\05 May 19\Germany Retail\APE12A.xlsx"), null, true),
    APE12A_Sheet =Sourcexl{[Item="APE12A",Kind="Sheet"]}[Data],
    #"Promoted Headersxl" =Table.PromoteHeaders(APE12A_Sheet, [PromoteAllScalars=true]),
    #"Changed Typexl" =Table.TransformColumnTypes(#"PromotedHeadersxl",{{"BREAKLVL", Int64.Type}, {"OVERFLOW",type text}, {"SUPN15", type text}, {"SNAM05", type text},{"PER", Int64.Type}, {"BBAL1501", type number}}),
    #"Grouped Rowsxl" =Table.Group(#"Changed Typexl", {"SUPN15","SNAM05"}, {{"Value", each List.Sum([BBAL1501]), typenumber}}),
    #"Filtered Rowsxl" =Table.SelectRows(#"Grouped Rowsxl", each ([SUPN15] <>" "))

    Source =Csv.Document(File.Contents("L:\Accounts Payable\Month End-AP\Month EndReports\2019\05 May 19\NB UK\APE12A.CSV"), [Delimiter=",",Columns=6, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    #"Promoted Headers" =Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Changed Type" =Table.TransformColumnTypes(#"PromotedHeaders",{{"BREAKLVL", Int64.Type}, {"OVERFLOW", typetext}, {"SUPN15", type text}, {"SNAM05", type text},{"PER", Int64.Type}, {"BBAL1501", type number}}),
    #"Trimmed Text" =Table.TransformColumns(#"Changed Type",{{"SUPN15",Text.Trim, type text}}),
    #"Grouped Rows" =Table.Group(#"Trimmed Text", {"SUPN15","SNAM05"}, {{"Value", each List.Sum([BBAL1501]), typenumber}}),
    #"Filtered Rows" =Table.SelectRows(#"Grouped Rows", each ([SUPN15] <>""))

    #"Table Ready" = if Bool then#"Filtered Rows" else #"Filtered Rowsxl",

    in
    #"Table Ready"



    And itstelling me “Token Comma expected”, and I have no idea why, when I click “ShowError” it points me to the
    Source = Csv.
    Any pointersto where I am going wrong would be hugely appreciated.

    Thanks,

  2. #2
    Board Regular sandy666's Avatar
    Join Date
    Oct 2015
    Posts
    2,585
    Post Thanks / Like
    Mentioned
    20 Post(s)
    Tagged
    1 Thread(s)

    Cool Re: Token Comma expected error - Trying to Select Data Source based on True/False

    try to remove this comma and add this


    #"Filtered Rowsxl" =Table.SelectRows(#"Grouped Rowsxl", each ([SUPN15] <>" ")),
    ....
    #"Filtered Rows" =Table.SelectRows(#"Grouped Rows", each ([SUPN15] <>"")),
    #"Table Ready" = if Bool then#"Filtered Rows" else #"Filtered Rowsxl",

    in
    #"Table Ready"

    end next time use:[CODE]your code here[/CODE]
    Last edited by sandy666; Jun 14th, 2019 at 04:36 AM.
    I know you know but I forgot my Crystal Ball and don't know what you know



    In the first post, show the type of machine (PC / Mac) and the Office version you are working on
    impossible things we do on the spot. for miracles you need to wait for a while

  3. #3
    New Member
    Join Date
    Jun 2019
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Token Comma expected error - Trying to Select Data Source based on True/False

    That's got it!

    Thank you very much, and I will take note for next time.

  4. #4
    Board Regular sandy666's Avatar
    Join Date
    Oct 2015
    Posts
    2,585
    Post Thanks / Like
    Mentioned
    20 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Token Comma expected error - Trying to Select Data Source based on True/False

    You are welcome

    Have a nice day
    I know you know but I forgot my Crystal Ball and don't know what you know



    In the first post, show the type of machine (PC / Mac) and the Office version you are working on
    impossible things we do on the spot. for miracles you need to wait for a while

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •