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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Mic1979
Post Partisan
Post Partisan

Cells Offset

Dear all,

 

I need to shift the cells on the right in my workload.

 

The idea is this:

1. I need to check what stored is in the column "Name".

2. If in the cells of the column "Name" I have the word "Labour", then the value stored in the column "Part Number", needs to put in the column "Labour Cost (MATURE). Differently, no change

 

Mic1979_0-1747905389752.png

 

I thought to this code:

OffsetLabour = Table.FromRecords(
Table.TransformRows(#"Changed Type1",
(r)=> Record.TransformFields(
r, {{"Name", each if Text.Contains(_,"Labour") then r[#"Labour Cost (MATURE)"]=r[#"Part Number"] else null}})))

 

However, this is not working

Mic1979_1-1747905550379.png

 

Could you support?

Thanks

1 ACCEPTED SOLUTION
AlienSx
Super User
Super User

    OffsetLabour = ((cols) => Table.SplitColumn(
        Table.CombineColumns(
            #"Changed Type1", 
            cols, 
            (x) => if Text.Contains(x{0}, "Labour") then {x{0}, x{2}, x{1}} else x,
            "combined"
        ),
        "combined", 
        (x) => x, 
        cols
    ))({"Name", "Part Number", "Labour Cost (MATURE)"})

View solution in original post

3 REPLIES 3
Mic1979
Post Partisan
Post Partisan

Thanks for your suggestions.

 

In the meatime, i made the following:

 

OffsetLabour = Table.FromRecords(
Table.TransformRows(#"Added Custom",
(r)=> Record.TransformFields(
r,
{
{"Labour Cost (MATURE)", each if Text.Contains(r[Name],"Labour") then r[#"Part Number"] else null},
{"Part Number", each if Text.Contains(r[Name],"Labour") then null else _}
}
)
)
),

slorin
Super User
Super User

Hi @Mic1979 

 

...
OffsetLabour1 = Table.ReplaceValue(#"Changed Type1", each Text.Contains([Name],"Labour"), each [#"Part Number"],
(actual, test, new) => if test then new else actual, {"Labour Cost (MATURE)"}),
OffsetLabour2 = Table.ReplaceValue(OffsetLabour1, each Text.Contains([Name],"Labour"), null,
(actual, test, new) => if test then new else actual, {"Part Number"})
...

Stéphane

AlienSx
Super User
Super User

    OffsetLabour = ((cols) => Table.SplitColumn(
        Table.CombineColumns(
            #"Changed Type1", 
            cols, 
            (x) => if Text.Contains(x{0}, "Labour") then {x{0}, x{2}, x{1}} else x,
            "combined"
        ),
        "combined", 
        (x) => x, 
        cols
    ))({"Name", "Part Number", "Labour Cost (MATURE)"})

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors