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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Nicole_H
Frequent Visitor

Repeat row answers in a new column

Hi all,

 

I have a table of info on users, projects and their status.  I need a sort of master column that returns 'Closed' for every user ID if any of their projects are closed.  I have done it before in a 2 steps, where I extracted the value I wanted into a new column, then repeated against every ID in a second column.

 

Looking to do this in Power/M query

 

Thanks!

 

User IDProjectStatusNew Column 1 New Column 2
15123OneClosedClosedClosed
15123TwoClosedClosedClosed
246599OneClosedClosedClosed
246599TwoOpen Closed
331743OneClosedClosedClosed
331743TwoOpen Closed
425826OneOpen  
425826TwoOpen  
654736OneClosedClosedClosed
654736TwoClosedClosedClosed
713418OneClosedClosedClosed
713418TwoOpen Closed
872406OneOpen Closed
872406TwoClosedClosedClosed
905117OneOpen  
905117TwoOpen  
966066OneOpen  
966066TwoOpen  
1 ACCEPTED SOLUTION
v-mdharahman
Community Support
Community Support

Hi @Nicole_H,

Thanks for reaching out to the Microsoft fabric community forum.

You can achieve this in Power Query using grouping and merging logic. Here's a simple approach that should give you the desired result first load your table into Power Query then group the data by User ID and create a new column that checks if any of the statuses for that user are "Closed":

let
Source = YourTableName,
Grouped = Table.Group(Source, {"User ID"}, {
{"AnyClosed", each List.ContainsAny([Status], {"Closed"}), type logical}
})
in
Grouped

Now merge this grouped table back with your original table using User ID as the key and add a custom column to return "Closed" if AnyClosed is true, otherwise leave it blank (if [AnyClosed] then "Closed" else null). Remove helper columns if needed and rename your new column to Master Status or whatever suits your needs.

This method avoids manual steps and ensures that the "Closed" status is consistently applied across all rows for each user.

 

If I misunderstand your needs or you still have problems on it, please feel free to let us know.  

Best Regards,
Hammad.

View solution in original post

5 REPLIES 5
jgeddes
Super User
Super User

Here is a solution that does not require merging.

let
    Source = 
    Table.FromRows(
        Json.Document(
            Binary.Decompress(
                Binary.FromText(
                    "bY87DsIwEAXv4jqF92/XHCANXZQOdyiJlILrg0BawN7GxRuPxl6WBAJIaUrz1l7n5b6f7ZbW6Quuj/0fIKvUGilOPs58tO29E4FxGHHSGYxSUN0Y9+6+ChtpVHAy/MOAGErkOOkqxZBz8Crfh0bNAmCj4XtXqKpZg4Lvv/fXJw==", 
                    BinaryEncoding.Base64
                ), 
                Compression.Deflate
            )
        ), 
        let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"User ID" = _t, Project = _t, Status = _t]
    ),
    #"Changed Type" = 
    Table.TransformColumnTypes(
        Source,
        {
            {"User ID", Int64.Type}, 
            {"Project", type text}, 
            {"Status", type text}
        }
    ),
    #"Grouped Rows" = 
    Table.Group(
        #"Changed Type", 
        {"User ID"}, 
        {
            {"AllRows", each _, type table [User ID=nullable number, Project=nullable text, Status=nullable text]}
        }
    ),
    Custom1 = 
    Table.TransformColumns(
        #"Grouped Rows", 
        {
            {"AllRows", each Table.AddColumn(_, "ID_Status", (r)=> if List.Contains([Status], "Closed") then "Closed" else "Open", type text), type table}
        }
    ),
    #"Expanded AllRows" = 
    Table.ExpandTableColumn(
        Custom1, 
        "AllRows", 
        {"Project", "ID_Status"}, 
        {"Project", "ID_Status"}
    )
in
    #"Expanded AllRows"

 

jgeddes_0-1751981821379.png

This uses your sample data. To implement in your code, change the Source line to your Source.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thanks, I finally got this to work!

Nicole_H
Frequent Visitor

Sorry, I missed the step about grouping by the ID, I'm not sure what to chose when I click on group by (I've never done this before)

Nicole_H
Frequent Visitor

Thanks for your reply.  I've tried to do this, but I get the error:

Expression.Error: A cyclic reference was encountered during evaluation.

v-mdharahman
Community Support
Community Support

Hi @Nicole_H,

Thanks for reaching out to the Microsoft fabric community forum.

You can achieve this in Power Query using grouping and merging logic. Here's a simple approach that should give you the desired result first load your table into Power Query then group the data by User ID and create a new column that checks if any of the statuses for that user are "Closed":

let
Source = YourTableName,
Grouped = Table.Group(Source, {"User ID"}, {
{"AnyClosed", each List.ContainsAny([Status], {"Closed"}), type logical}
})
in
Grouped

Now merge this grouped table back with your original table using User ID as the key and add a custom column to return "Closed" if AnyClosed is true, otherwise leave it blank (if [AnyClosed] then "Closed" else null). Remove helper columns if needed and rename your new column to Master Status or whatever suits your needs.

This method avoids manual steps and ensures that the "Closed" status is consistently applied across all rows for each user.

 

If I misunderstand your needs or you still have problems on it, please feel free to let us know.  

Best Regards,
Hammad.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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