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
Anonymous
Not applicable

Create new column that evaluates a series of conditions to be met

 

Hi Everyone,

 

So here is the problem I need help with. Ive attached a sample table of the dataset below. I need to create a column called "Linked Task" which evaluates when a Row# has all its dependencies in the "Dependency Plan" column with a "Predecessor Row#" of that plan.

Columns "Row#", "Plan" and "Task" are static.
Columns "Predecessor Row#" and "Dependency Plan" are manually populated, and therefore I need to detect outliers.

 

Each Row# can have none, one or more Predecessor Row#.

Each Row# can have none, one or more Dependency Plans.

A few examples of the logic the new column should have:

Row#2 should give me an output of "Linked" in the new column because the Predecessor "Row# 1" in that row is part of the Plan A marked in the Dependency column.

Row#3 should give me an output of "Linked" because both Predecessor Row# 1 and #2 are part of Plan A.

Row#4 should give me an output of "Not Linked" because I have no Predecessor Row# marked for the dependency of Plan A.

Row#5 should give me an output of "Not Linked" because Predecessor Row#3 is part of Plan A, but Predecessor Row#7 is not (it is Plan B, and I dont have Plan B in the Dependency Plan column) 


PBIX Sample Data  

Row#PlanTaskPrecedessor Row#Dependency Plan
1Plan ATask A1  
2Plan ATask A21Plan A
3Plan ATask A31, 2Plan A
4Plan ATask A4 Plan A
5Plan ATask A53, 7Plan A
6Plan ATask A6  
7Plan BTask B12Plan A
8Plan BTask B24, 5Plan A
9Plan BTask B36, 12Plan A, Plan B
10Plan BTask B45Plan B
11Plan BTask B510Plan B
12Plan BTask B6  
13Plan CTask C18Plan B
14Plan CTask C21, 10Plan A, Plan B, Plan C
15Plan CTask C39Plan B
16Plan CTask C4  
17Plan CTask C5 Plan A
18Plan CTask C64, 8, 17Plan A, Plan B, Plan C
19Plan CTask C74, 8, 17Plan A, Plan B
20Plan CTask C818, 19Plan C
21Plan CTask C912, 17Plan B, Plan C
22 Task X1Plan A
23 Task Y10Plan B
24 Task Z20Plan C

 

I have tried creating support tables to split the information but to no avail, so Im going back to square one and see which is the best approach.

 

Thanks for your help,

Regards

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try the following methods.

Measure:

Linked Task =
VAR N1 =
    CALCULATE (
        COUNT ( Predecessors[Predecessor#] ),
        FILTER (
            ALL ( 'Fact Table' ),
            [Row#] = SELECTEDVALUE ( Predecessors[Row#] )
                && [Precedessor] <> BLANK ()
        )
    )
VAR N2 =
    CALCULATE (
        COUNT ( 'Dependencies'[Value] ),
        FILTER (
            ALL ( 'Fact Table' ),
            [Row#] = SELECTEDVALUE ( 'Dependencies'[Row#] )
                && [Dependency] <> BLANK ()
        )
    )
RETURN
    IF ( N1 >= 1 && N2 >= 1, "Linked", "Not Linked" )

vzhangti_0-1659691518802.png

In your data, row 5 is 3, 4, so output Linked.

Column:

Linked Task C = 
VAR N1 =
    CALCULATE (
        COUNT ( Predecessors[Predecessor#] ),
        FILTER (Predecessors ,
            [Row#] = EARLIER('Fact Table'[Row#])
                && [Precedessor] <> BLANK ()
        )
    )
VAR N2 =
    CALCULATE (
        COUNT ( 'Dependencies'[Value] ),
        FILTER ('Dependencies' ,
            [Row#] = EARLIER('Fact Table'[Row#])
                && [Dependency] <> BLANK ()
        )
    )
RETURN
    IF ( N1 >= 1 && N2 >= 1, "Linked", "Not Linked" )

vzhangti_1-1659691808548.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

1 REPLY 1
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try the following methods.

Measure:

Linked Task =
VAR N1 =
    CALCULATE (
        COUNT ( Predecessors[Predecessor#] ),
        FILTER (
            ALL ( 'Fact Table' ),
            [Row#] = SELECTEDVALUE ( Predecessors[Row#] )
                && [Precedessor] <> BLANK ()
        )
    )
VAR N2 =
    CALCULATE (
        COUNT ( 'Dependencies'[Value] ),
        FILTER (
            ALL ( 'Fact Table' ),
            [Row#] = SELECTEDVALUE ( 'Dependencies'[Row#] )
                && [Dependency] <> BLANK ()
        )
    )
RETURN
    IF ( N1 >= 1 && N2 >= 1, "Linked", "Not Linked" )

vzhangti_0-1659691518802.png

In your data, row 5 is 3, 4, so output Linked.

Column:

Linked Task C = 
VAR N1 =
    CALCULATE (
        COUNT ( Predecessors[Predecessor#] ),
        FILTER (Predecessors ,
            [Row#] = EARLIER('Fact Table'[Row#])
                && [Precedessor] <> BLANK ()
        )
    )
VAR N2 =
    CALCULATE (
        COUNT ( 'Dependencies'[Value] ),
        FILTER ('Dependencies' ,
            [Row#] = EARLIER('Fact Table'[Row#])
                && [Dependency] <> BLANK ()
        )
    )
RETURN
    IF ( N1 >= 1 && N2 >= 1, "Linked", "Not Linked" )

vzhangti_1-1659691808548.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

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.