Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
bhaskarpbi999
Helper III
Helper III

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..

 

bhaskarpbi999_0-1714315717570.png

 

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

 

1 ACCEPTED SOLUTION
v-jialongy-msft
Community Support
Community Support

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.

View solution in original post

2 REPLIES 2
v-jialongy-msft
Community Support
Community Support

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.

Hi Jayleny,

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

 

Regards,

Bhaskar

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.