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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hixkim
Frequent Visitor

Identifying rows of data based on a single value on one row only.

Hello! I am using PO data with PO numbers, line numbers, and part numbers (there are many more columns but they are not relevant). I would like to identify an entire PO and all associated PO lines based on a single part number within that PO. The other PO lines will have different part numbers but I still need them identified based on a value in another PO line.

There are only 2 part numbers that I need to identify so I can store these within the actual formula or create a separate table to store them in. I like the table idea in case the part numbers grow or shrink but I am open to any solution. 

 

I am trying to accomplish this within Power Query in Power BI. I have no idea where to start on this one. I really appreciate any help at all. 

 

Thank you!!

 

Example:

PO NumberPart NumberLine NumberExpected Result
111111231PART 123
111114562PART 123
111117893PART 123
111110124PART 123
111113455PART 123
222221231PART 123
222224562PART 123
222227893PART 123
333334561 
333337892 
333330123 
333333454 
7 REPLIES 7
watkinnc
Super User
Super User

Sorry, you can use the Add Columns and FillDown options right from the GUI.

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

Thanks Nate. That seems to be filling down the item number from Line 1 only. I am looking for it to fill in 2 specific part numbers only (600121 or 600122) whenever one of them exists on one of the order lines. They can exist on any order line or none at all. 

watkinnc
Super User
Super User

This works:

PartsColumn = Table.AddColumn(PreviousStepName, "Part_Numbers", each if [Line Number] = 1 then [Part Number] else null, type text),

Fill = Table.FillDown(PartsColumn, {"Part_Numbers"})

in

Fill

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

I'm sorry to even ask but could you show me how you would enter this? Maybe I would have been better off posting in the regular Power BI forum, I'm a little out of my depth. I've tried entering this in a few places and have tried googling how to enter this kind of statement but I am having a ton of luck. 

 

Also, in my sample data the part number happened to be on the first order line but that's not always (or even often) the case. Would that statement only work if the part number was listed on the first line?

 

Thanks for your help. 

Jakinta
Solution Sage
Solution Sage

I am not quite sure what do you want exactly...Maybe this can help...

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XY7BDcAwCAN34Z1HgdC0s0TZf41CUdK4fvhxsmX3ThyiQiwaTqN8rNrpLsDadbsrsIMl0sC0mru9TEK/jcn2jcn2DQ2tHAPLnADLL9jNL/5vPA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"PO Number" = _t, #"Part Number" = _t, #"Line Number" = _t]),
    Grouped = Table.Group(Source, {"PO Number"}, {{"GR", each if List.Contains (_ [Part Number], "123") then Table.AddColumn(_,"Expected", each "PART 123") else Table.AddColumn(_,"Expected", each "") }}),
    #"Expanded GR" = Table.ExpandTableColumn(Grouped, "GR", {"Part Number", "Line Number", "Expected"})
in
    #"Expanded GR"

Jakinta_0-1623424005672.png

 

 

Sorry that's going over my head a bit. I have an excel data source with 45k lines. There are thousands of orders and each order has at least one order line. I want to evaluate each order to see if it has a specific part number (there are only 2 part numbers I care about, I need to check the orders for either, no order would have both). If it has that specific part number I would like a text value related to that part number to appear for each line of the order. I'm looking for the formula I could use to create that custom text column. 

 

I don't know if this explanation helped or made it worse. I really appreciate the effort. 

Try this with 2 text parameters for Parts. You have to create them and use in query below.

Jakinta_0-1623441797464.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XY67EcAwCEN3oXZhfvnM4vP+awSC7ZioUPFOCLUG6IICSOwOvXxM9DCnxM7rNufEKpKnE2NRc30ZuX4/Jtt/TLb/YNfKYWKRo8RiS76NLbFPxEMVV9kAtJoG4KjpDw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"PO Number" = _t, #"Part Number" = _t, #"Line Number" = _t]),
    Grouped = Table.Group(Source, {"PO Number"}, {{"GR", each if List.Contains(_ [Part Number], Part1) then Table.AddColumn(_,"Expected", each "PART "& Part1) else if List.Contains(_ [Part Number], Part2) then Table.AddColumn(_,"Expected", each "PART "& Part2) else
    Table.AddColumn(_,"Expected", each "") }}),
    #"Expanded GR" = Table.ExpandTableColumn(Grouped, "GR", {"Part Number", "Line Number", "Expected"})
in
    #"Expanded GR"

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.

Top Solution Authors
Top Kudoed Authors