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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
nbufff
Helper I
Helper I

Help! How to use Powery Query to match value in the above rows

Dear community,

I encountered a problem when dealing with power query in Power BI.

It seemed simple in Excel

eg. B3=IF(MATCH(A3,$A$2:A2,0),"Sharing","").

      B4=IF(MATCH(A4,$A$2:A3,0),"Sharing","")

      B5=IF(MATCH(A5,$A$2:A4,0),"Sharing","")

Basically Column B is to check the value above, if found then return as "Sharing" or showing #N/A.

 

How can we make it done in Power Query by adding the custom column from Column A?

Appreciate the help! 

2024-09-12_11h19_48.png

1 ACCEPTED SOLUTION
shafiz_p
Super User
Super User

Hi @nbufff  You can acheive this using index column, List.Contains and List.FirstN function. First create a index column in power query. See image below:

shafiz_p_0-1726118612373.png

 

Now create a custom column to identify matching values above. Go to home tab and click advance editor. Create a custom column to identify. See image below:

shafiz_p_1-1726118803383.png

 

Here is the custom column, where #"Added Index" is the previous steps:

    Matching = Table.AddColumn(#"Added Index", "MatchingAbove", 
        each if List.Contains(List.FirstN(#"Added Index"[Material], [Index]-1), [Material]) then "Sharing" else "")

 

You will get your desired result. See image below:

shafiz_p_2-1726118879444.png

Now you can remove the index column. That's it.

 



Hope this helps!!
If this solved your problem, please accept it as a solution!!

Best Regards,
Shahariar Hafiz

View solution in original post

2 REPLIES 2
shafiz_p
Super User
Super User

Hi @nbufff  You can acheive this using index column, List.Contains and List.FirstN function. First create a index column in power query. See image below:

shafiz_p_0-1726118612373.png

 

Now create a custom column to identify matching values above. Go to home tab and click advance editor. Create a custom column to identify. See image below:

shafiz_p_1-1726118803383.png

 

Here is the custom column, where #"Added Index" is the previous steps:

    Matching = Table.AddColumn(#"Added Index", "MatchingAbove", 
        each if List.Contains(List.FirstN(#"Added Index"[Material], [Index]-1), [Material]) then "Sharing" else "")

 

You will get your desired result. See image below:

shafiz_p_2-1726118879444.png

Now you can remove the index column. That's it.

 



Hope this helps!!
If this solved your problem, please accept it as a solution!!

Best Regards,
Shahariar Hafiz

That's really helpful!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.