Forum Discussion

bhaskarpbi999's avatar
2 years ago
Solved

Get matching data from a Source file based on condition - Power Query

Hi ,

 

i have a source file (CSV) and i need matching data with all columns based on condition Day Date = Week End date usingPower Queryand data screeenshot is below..

 

 

Code in power query editor 

 

let

//I. GET DYNAMIC PATH
SourceRPT= PRM_SOURCES{[NAME="DIR XML"]}[PRM],

//2. CSV, adjust Delimiter type and Columns accordingly
Source = Csv.Document(File.Contents(SourceRPT),[Delimiter=",", Columns=6, Encoding=1252, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])
in
#"Promoted Headers"

 

 

Could you please help me with code i need to use.

 

Regards,

Bhaskar

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi bhaskarpbi999

     

    You can add a custom column to flag rows where the Day Date matches the Week End date.

    #"Added Custom" = Table.AddColumn(#"Promoted Headers", "Match", each if [Day Date] = [Week End Date] then "Match" else "No Match")

     

     

     

    Your final code in the Power Query Editor will look something like this:

    let
        //I. GET DYNAMIC PATH
        SourceRPT= PRM_SOURCES{[NAME="DIR XML"]}[PRM],
        //2. CSV, adjust Delimiter type and Columns accordingly
        Source = Csv.Document(File.Contents(SourceRPT),[Delimiter=",", Columns=6, Encoding=1252, QuoteStyle=QuoteStyle.None]),
        #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
        #"Added Custom" = Table.AddColumn(#"Promoted Headers", "Match", each if [Day Date] = [Week End Date] then "Match" else "No Match"),
       
    in
        #"Added Custom"

     

     

     

    Best Regards,

    Jayleny

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi bhaskarpbi999

     

    You can add a custom column to flag rows where the Day Date matches the Week End date.

    #"Added Custom" = Table.AddColumn(#"Promoted Headers", "Match", each if [Day Date] = [Week End Date] then "Match" else "No Match")

     

     

     

    Your final code in the Power Query Editor will look something like this:

    let
        //I. GET DYNAMIC PATH
        SourceRPT= PRM_SOURCES{[NAME="DIR XML"]}[PRM],
        //2. CSV, adjust Delimiter type and Columns accordingly
        Source = Csv.Document(File.Contents(SourceRPT),[Delimiter=",", Columns=6, Encoding=1252, QuoteStyle=QuoteStyle.None]),
        #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
        #"Added Custom" = Table.AddColumn(#"Promoted Headers", "Match", each if [Day Date] = [Week End Date] then "Match" else "No Match"),
       
    in
        #"Added Custom"

     

     

     

    Best Regards,

    Jayleny

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • bhaskarpbi999's avatar
      bhaskarpbi999
      Helper V

      Hi Jayleny,

      I am accepting solution and Kudos to you. Thanks for your support.

       

      Regards,

      Bhaskar