Forum Discussion

shamwoo's avatar
shamwoo
Frequent Visitor
7 years ago
Solved

Limited Records Imported Based on Date

Hi All,

 

I've found some code to pull 3-years worth of data dynamically. It is giving me a 'Token Comma expected' error on #"Filtered Rows" however. Would you please provide any thoughts or suggestions on how to troubleshoot the following code? Thank you in advance! 

 

let
    Source = Salesforce.Data(),
    #"Year" = Date.Year(DateTime.LocalNow())-3,
    Opportunity1 = Source{[Name="Opportunity"]}[Data]
    #"Filtered Rows" = Table.SelectRows(Opportunity1, each Date.Year([LastModifiedDate]) >= #"Year")
in
    #"Filtered Rows
  • In "M" you need "," at end of each line between 'let' & 'in' except at last line before 'in'. (Excluding line continuation)

     

    Looks like you are missing "," at Opportunity1 line.

  • Hi shamwoo,

     

    Please update your code as below and try again.

     

    let
        Source = Salesforce.Data(),
        #"Year" = Date.Year(DateTime.LocalNow())-3,
        Opportunity1 = Source{[Name="Opportunity"]}[Data],
        #"Filtered Rows" = Table.SelectRows(Opportunity1, each Date.Year([LastModifiedDate]) >= #"Year")
    in
        #"Filtered Rows

    Regards,

    Frank

3 Replies

  • Chihiro's avatar
    Chihiro
    Icon for Solution Sage rankSolution Sage

    In "M" you need "," at end of each line between 'let' & 'in' except at last line before 'in'. (Excluding line continuation)

     

    Looks like you are missing "," at Opportunity1 line.

  • v-frfei-msft's avatar
    v-frfei-msft
    Icon for Community Support rankCommunity Support

    Hi shamwoo,

     

    Please update your code as below and try again.

     

    let
        Source = Salesforce.Data(),
        #"Year" = Date.Year(DateTime.LocalNow())-3,
        Opportunity1 = Source{[Name="Opportunity"]}[Data],
        #"Filtered Rows" = Table.SelectRows(Opportunity1, each Date.Year([LastModifiedDate]) >= #"Year")
    in
        #"Filtered Rows

    Regards,

    Frank

    • v-frfei-msft's avatar
      v-frfei-msft
      Icon for Community Support rankCommunity Support

      Hi shamwoo,

       

      Does that make sense? If so, kindly mark the answer as solution to close the case.


      Regards,
      Frank