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

Add new colum with values iterating over 2 other colum values

Hi every one,

 

I want to add a new column in my report and i don't know how to do it.

Here's an example of my data source

 

IndexIndentation LevelTask IDTask NameParent Task IdExpected Result
11id1Task1? 
22id2Task1.1?id1
33id3Task1.1.1?id2
44id4Task1.1.1.1?id3
55id5Task1.1.1.1.1?id4
65id6Task1.1.1.1.2?id4
73id7Task1.1.2?id2
84id8Task1.1.2.1?id7
95id9Task1.1.2.1.1?id8
104id10Task1.1.2.2?id7
115id11Task1.1.2.2.1?id10

 

I want to fill the "Parent Task Id" column with the values showed in the "Expected Result" (this column isn't part of my data source, it's just in my example to show the expected values) values

 

How can I fill the "Prent Task Id" with the values of the "Task ID" column and depending on the indentation level of each taks?

 

Tanks for helping.

1 ACCEPTED SOLUTION

This seems to return the correct results.

 

Column = MAXX(FILTER(ALL('Table6'),[Indentation Level]<EARLIER([Indentation Level]) && [Index] < EARLIER([Index])),[Task ID])

See Table6 of attached.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

HI @ivanpuente,

 

You can try to use following calculate column formula to use task name to find out correspond parent task name and task id.

Parent Task =
VAR _indexList =
    SUBSTITUTE ( [Task Name], "Task", "" )
VAR _path =
    SUBSTITUTE ( _indexList, ".", "|" )
VAR _parent =
    "Task"
        & IF (
            LEN ( _indexList ) > 1,
            LEFT (
                _indexList,
                LEN ( _indexList )
                    - LEN ( PATHITEM ( _path, PATHLENGTH ( _path ) - 1 ) )
                    - 1
            ),
            _indexList
        )
RETURN
    IF (
        _parent <> [Task Name],
        LOOKUPVALUE ( Table2[Task ID], Table2[Task Name], _parent )
    )

5.png

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi,

 

this solution is a good option, but in my example I've used some dummy Task Name values. In real case the Task Name can't be used, because it's free text, so the people can write anything in it.

 

My real problem needs to get the id from the line having the first indentation level before my line.

 

So for a line where Indentation Level is 3 (Lines 3 and 7) I want to get the Taks Id of the line with the first appearence of previous level (2 in this case), so the Line number 2.

In the  case of line 7 I should go up in the line till I find the first appearance of number 2.

The same way for the line 5 and 6 I want to go up 1 or 2 times to get the first appearance of level 4.

 

I hope my explanation is clear, and thanks for the reply.

This seems to return the correct results.

 

Column = MAXX(FILTER(ALL('Table6'),[Indentation Level]<EARLIER([Indentation Level]) && [Index] < EARLIER([Index])),[Task ID])

See Table6 of attached.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

You need to use EARLIER. So basically, you need to get the MAX of Indentation Level for ALL of your table where you FILTER Indentation Level < EARLIER of your Indentation Level and you also will have to take into account your Task Name somehow. Once you have that then you can essentially "lookup" your Task ID for that Indentation level and return that. See my article on Mean Time Before Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.