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
txcvega
Frequent Visitor

Retrieve text value from field in a Parent Task using WBS

I am hoping to get a bit of direction with my issue. 

 

I am connecting to a Project Online database to retrieve the Tasks table where I am attempting to get a text value from a Parent Task using WBS to populate to all the Child Tasks. 

 

Example of my data:

In a project schedule, we have Scheduled tasks (e.g. ABC-01-002263-03-Scheduled Task) that are under a Timesheet summary task. These scheduled tasks are assigned to resources so the task appears on their weekly timesheet. Resources also have the ability to add Ad Hoc tasks (e.g. abc-01-002263-03-Ad Hoc Task) into their timesheets that are designated Child tasks of already scheduled tasks. Every task has an ERP ID field that displays ERP sync data. 

Is Summary WBS Task Name ERP ID
TRUE11.1.11TimesheetsTimesheets - ABC-01-002263
TRUE11.1.11.1ABC-01-002263-03-Scheduled TaskABC-01-002263-03
FALSE11.1.11.1.1abc-01-002263-03-Ad Hock Task000000035703-0010-
TRUE11.1.11.4ABC-01-002263-06-Scheduled TaskABC-01-002263-06
FALSE11.1.11.4.1abc-01-002263-06-Ad Hock Task 1000000035703-0070-
FALSE11.1.11.4.2abc-01-002263-06-Ad Hock Task 2000000035703-0070-
FALSE11.1.11.4.3abc-01-002263-06-Ad Hock Task 3000000035703-0070-
FALSE11.1.11.4.4abc-01-002263-06-Ad Hock Task 4000000035703-0070-
TRUE11.2.11TimesheetsTimesheets - ABC-01-001908
TRUE11.2.11.1ABC-01-001908-04-Scheduled TaskABC-01-001908-04
FALSE11.2.11.1.1abc-01-001908-04-Ad Hock Task000000030480-0030-
TRUE11.2.11.2ABC-01-001908-75-Scheduled TaskABC-01-001908-75
FALSE11.2.11.2.1abc-01-001908-75-Ad Hock Task000000030480-0150-

 

My issue is to be able to grab text values from the parent task ERP ID field and populate all nodes in the same WBS with a portion of the ERP ID info into a new field (Parent ERP ID).

Is Summary WBS Task Name ERP IDParent ERP ID
TRUE11.1.11TimesheetsTimesheets - ABC-01-002263ABC-01-002263
TRUE11.1.11.1ABC-01-002263-03-Scheduled TaskABC-01-002263-03ABC-01-002263
FALSE11.1.11.1.1abc-01-002263-03-Ad Hock Task000000035703-0010-ABC-01-002263
TRUE11.1.11.4ABC-01-002263-06-Scheduled TaskABC-01-002263-06ABC-01-002263
FALSE11.1.11.4.1abc-01-002263-06-Ad Hock Task 1000000035703-0070-ABC-01-002263
FALSE11.1.11.4.2abc-01-002263-06-Ad Hock Task 2000000035703-0070-ABC-01-002263
FALSE11.1.11.4.3abc-01-002263-06-Ad Hock Task 3000000035703-0070-ABC-01-002263
FALSE11.1.11.4.4abc-01-002263-06-Ad Hock Task 4000000035703-0070-ABC-01-002263
TRUE11.2.11TimesheetsTimesheets - ABC-01-001908ABC-01-001908
TRUE11.2.11.1ABC-01-001908-04-Scheduled TaskABC-01-001908-04ABC-01-001908
FALSE11.2.11.1.1abc-01-001908-04-Ad Hock Task000000030480-0030-ABC-01-001908
TRUE11.2.11.2ABC-01-001908-75-Scheduled TaskABC-01-001908-75ABC-01-001908
FALSE11.2.11.2.1abc-01-001908-75-Ad Hock Task000000030480-0150-ABC-01-001908

 

Is it easier to do this in Power Query or in the report using DAX? Any suggestions?

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Here is one way to get your desired result from your example data.  To see how it works, just create a blank query, go to Advanced Editor, and replace the text there with the M code below.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZK9DoIwEIBfpWGm5PrDjyMajYOT4EQYEJpg0Dig7y8gxBQOKu3QNr37+jV3SWLF58vesi3GnGayZhffHqoulXrV2oFQEm53FBgF4NwTVmqPk502XQuiIGiUl6p431VB4qyukIiOdAhPkYbqYNk112FhQY7PvBpQ8B3C9Zs7AAYU05LTRz2jlodqSUzL07QIm4r5vdgUx404vgYnjDixBieNODmP+1WB/91ZbAMBkqx3VhtEQS6UsI8Y/4ojnTXAZjoLZAC0XbE/ddXTH/Vdk5bvoloc0Wpgi1rMbbXSDw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Is Summary " = _t, #"WBS " = _t, #"Task Name " = _t, #"ERP ID" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Is Summary ", type logical}, {"WBS ", type text}, {"Task Name ", type text}, {"ERP ID", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [#"Task Name "] = "Timesheets" then Text.AfterDelimiter([ERP ID], "-") else Text.BeforeDelimiter([#"Task Name "], "-", 2)),
    #"Trimmed Text" = Table.TransformColumns(#"Added Custom",{{"Custom", Text.Trim, type text}})
in
    #"Trimmed Text"

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

1 REPLY 1
mahoneypat
Employee
Employee

Here is one way to get your desired result from your example data.  To see how it works, just create a blank query, go to Advanced Editor, and replace the text there with the M code below.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZK9DoIwEIBfpWGm5PrDjyMajYOT4EQYEJpg0Dig7y8gxBQOKu3QNr37+jV3SWLF58vesi3GnGayZhffHqoulXrV2oFQEm53FBgF4NwTVmqPk502XQuiIGiUl6p431VB4qyukIiOdAhPkYbqYNk112FhQY7PvBpQ8B3C9Zs7AAYU05LTRz2jlodqSUzL07QIm4r5vdgUx404vgYnjDixBieNODmP+1WB/91ZbAMBkqx3VhtEQS6UsI8Y/4ojnTXAZjoLZAC0XbE/ddXTH/Vdk5bvoloc0Wpgi1rMbbXSDw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Is Summary " = _t, #"WBS " = _t, #"Task Name " = _t, #"ERP ID" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Is Summary ", type logical}, {"WBS ", type text}, {"Task Name ", type text}, {"ERP ID", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [#"Task Name "] = "Timesheets" then Text.AfterDelimiter([ERP ID], "-") else Text.BeforeDelimiter([#"Task Name "], "-", 2)),
    #"Trimmed Text" = Table.TransformColumns(#"Added Custom",{{"Custom", Text.Trim, type text}})
in
    #"Trimmed Text"

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.