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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
tonybrogan
Advocate I
Advocate I

Calculated Column - Fill Using Text From Another Column

Hi Everyone,   I'm struggling creating a calculated column for my dataset to fix a report issue but I'm now left wondering if it is even possible as I'm only using text fields (nothing numeric).

I've spent hours looking for a solution but struggling. 
Any help available is greatly appreciated. 

This is my dataset and creating the calculated column is the aim.

DocumentNoReferenceEmployeeCalculated Column
100ABC Joe Bloggs
100ABCJoe BloggsJoe Bloggs
110ABC Joe Bloggs
110ABC Joe Bloggs
110ABC Joe Bloggs
200DEF Harry Brown
200DEFHarry BrownHarry Brown
200DEF Harry Brown
300XYZ Steve Austin
300XYZ Steve Austin
300XYZ Steve Austin
300XYZ Steve Austin
310XYZ Steve Austin
310XYZSteve AustinSteve Austin
310XYZ Steve Austin
105XYZ Steve Austin
210XYZ Steve Austin

 
@HotChilli 

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @tonybrogan 

You can try the following solutions.

1.Put the following code to advanced editor in power query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwUNJRcnRyBpIKSrE6qCJe+akKTjn56enFEClDDMVEiBiBDXRxdcMq4pFYVFSp4FSUX56HQ7UxWCQiMopSEUN8IsElqWWpCo6lxSWZeTiUGxqYookYoaqJBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DocumentNo = _t, Reference = _t, Employee = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DocumentNo", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Reference"}, {{"Count", each List.Max([Employee]), type nullable text}, {"Data", each _, type table [DocumentNo=nullable number, Reference=nullable text, Employee=nullable text]}}),
    #"Expanded Data" = Table.ExpandTableColumn(#"Grouped Rows", "Data", {"DocumentNo", "Employee"}, {"DocumentNo", "Employee"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Expanded Data",{"Reference", "DocumentNo", "Employee", "Count"})
in
    #"Reordered Columns"

Output

vxinruzhumsft_0-1696215322922.png

 

2.You can create a calculated column

Column =
MAXX (
    FILTER (
        'Table (2)',
        [Reference] = EARLIER ( 'Table (2)'[Reference] )
            && [Employee] <> BLANK ()
    ),
    [Employee]
)

Output

vxinruzhumsft_1-1696215568362.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
v-xinruzhu-msft
Community Support
Community Support

Hi @tonybrogan 

You can try the following solutions.

1.Put the following code to advanced editor in power query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwUNJRcnRyBpIKSrE6qCJe+akKTjn56enFEClDDMVEiBiBDXRxdcMq4pFYVFSp4FSUX56HQ7UxWCQiMopSEUN8IsElqWWpCo6lxSWZeTiUGxqYookYoaqJBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DocumentNo = _t, Reference = _t, Employee = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DocumentNo", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Reference"}, {{"Count", each List.Max([Employee]), type nullable text}, {"Data", each _, type table [DocumentNo=nullable number, Reference=nullable text, Employee=nullable text]}}),
    #"Expanded Data" = Table.ExpandTableColumn(#"Grouped Rows", "Data", {"DocumentNo", "Employee"}, {"DocumentNo", "Employee"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Expanded Data",{"Reference", "DocumentNo", "Employee", "Count"})
in
    #"Reordered Columns"

Output

vxinruzhumsft_0-1696215322922.png

 

2.You can create a calculated column

Column =
MAXX (
    FILTER (
        'Table (2)',
        [Reference] = EARLIER ( 'Table (2)'[Reference] )
            && [Employee] <> BLANK ()
    ),
    [Employee]
)

Output

vxinruzhumsft_1-1696215568362.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Massive thanks Yolo Zhu, it worked perfectly.

mlsx4
Super User
Super User

Hi @tonybrogan 

 

This works for me:

 

 

let
    Origen = Excel.Workbook(File.Contents("C:\ex.xlsx"), null, true),
    Hoja1_Sheet = Origen{[Item="Hoja1",Kind="Sheet"]}[Data],
    #"Encabezados promovidos" = Table.PromoteHeaders(Hoja1_Sheet, [PromoteAllScalars=true]),
    #"Filas agrupadas" = Table.Group(#"Encabezados promovidos", {"NoReference"}, {{"Data", each Table.FillDown(_,{"Employee"}), type table [Document=number, NoReference=text, Employee=nullable text]}}),
    #"Se expandió Data" = Table.ExpandTableColumn(#"Filas agrupadas", "Data", {"Document", "NoReference", "Employee"}, {"Document", "NoReference.1", "Employee"}),
    #"Columnas quitadas" = Table.RemoveColumns(#"Se expandió Data",{"NoReference"}),
    #"Columnas con nombre cambiado" = Table.RenameColumns(#"Columnas quitadas",{{"NoReference.1", "NoReference"}}),
    #"Filas agrupadas1" = Table.Group(#"Columnas con nombre cambiado", {"NoReference"}, {{"Data", each Table.FillUp(_,{"Employee"}), type table [Document=nullable number, NoReference=nullable text, Employee=nullable text]}}),
    #"Se expandió Data1" = Table.ExpandTableColumn(#"Filas agrupadas1", "Data", {"Document", "NoReference", "Employee"}, {"Document", "NoReference.1", "Employee"}),
    #"Columnas quitadas1" = Table.RemoveColumns(#"Se expandió Data1",{"NoReference.1"}),
    #"Columnas reordenadas" = Table.ReorderColumns(#"Columnas quitadas1",{"Document", "NoReference", "Employee"})
in
    #"Columnas reordenadas"

 

 

My procedure is:

  • Group by Nºreference but putting in operation: All rows 
  • Then, where it puts each_ replace by each Table.FillDown(_,{"Employee"}).
  • Expand all the data. You will see, that you still have null values. So, I repeat the procedure, but instead of FillDown in the second step, you put FillUp

 

Hope I make it clear

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors