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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Add conditional rows

Hi - Any help on the following issue would be greatly appreciated!

 

End Goal - Import the correct Table2[No.] into Table1, based on [Entry No.]

   I believe the best way to do this is to > Merge Table1[Entry No.] with Table2[Entry No.] >> In Table1 > Expand Table2[No.]

Issue - Table2 does not currently have a column for [Entry No.]. Instead, it has 2 columns for [From Entry No.] and [To Entry No.]. So I need to find the values in between "From" and "To"

 

Table1:

Document No.Entry No.Expected Result
PAY74223811638207075
PAY74223811639207075
PAY74233811640207075
PAY74233811641207075
PAY74253811877207087
PAY74253811878207087
PAY74263811879207087
PAY74263811880207087
PAY74273811881207087
PAY74273811882207087

 

Table2:

No.From Entry No.To Entry No.
20707538116283811641
20707638116423811651
20707738116523811657
20707838116583811809
20707938118103811819
20708038118203811824
20708138118253811838
20708238118393811842
20708338118433811866
20708438118673811870
20708538118713811874
20708638118753811876
20708738118773811882
20708838118833811890
1 ACCEPTED SOLUTION
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Use this formula in Table1 for Result

= Table.SelectRows(Table2, (x)=> x[#"From Entry No."]<=[#"Entry No."] and x[#"To Entry No."]>=[#"Entry No."]){0}[#"No."]

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fcm7CcAwDAXAXVS7kOTPk8tskDYY779GUjgmEKHu4Mag87hQVClRNpGW7ZEyGJVm+nf3Or9dOG7xuq42YLXBbfO67e5hG3uN3RK3fnre", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Document No." = _t, #"Entry No." = _t, #"Expected Result" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Document No.", type text}, {"Entry No.", Int64.Type}, {"Expected Result", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Result", each Table.SelectRows(Table2, (x)=> x[#"From Entry No."]<=[#"Entry No."] and x[#"To Entry No."]>=[#"Entry No."]){0}[#"No."])
in
    #"Added Custom"

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

This worked great, thank you!!

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Use this formula in Table1 for Result

= Table.SelectRows(Table2, (x)=> x[#"From Entry No."]<=[#"Entry No."] and x[#"To Entry No."]>=[#"Entry No."]){0}[#"No."]

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fcm7CcAwDAXAXVS7kOTPk8tskDYY779GUjgmEKHu4Mag87hQVClRNpGW7ZEyGJVm+nf3Or9dOG7xuq42YLXBbfO67e5hG3uN3RK3fnre", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Document No." = _t, #"Entry No." = _t, #"Expected Result" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Document No.", type text}, {"Entry No.", Int64.Type}, {"Expected Result", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Result", each Table.SelectRows(Table2, (x)=> x[#"From Entry No."]<=[#"Entry No."] and x[#"To Entry No."]>=[#"Entry No."]){0}[#"No."])
in
    #"Added Custom"

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

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.

Top Solution Authors