cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kirthana67 Frequent Visitor
Frequent Visitor

Adding a new derived column to an existing table from a related table

I have two tables-

Table 1

“Id”                      “Values”

1                           1           

1                           0

1                           1

2                           1

2                           1

3                           1

4                           0

4                           1

4                           1

Table 2

Id                         Status

1                           No

2                           Yes

3                           Yes

4                           No

I need to add a column to Table 2, Status such that Status = Yes if all Values are 1, else “No”.

Can someone please help me out?

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisMendoza Senior Member
Senior Member

Re: Adding a new derived column to an existing table from a related table

@Kirthana67 -

Does this work for you?

Column = 
VAR t1Rows =
    CALCULATE(
        COUNTROWS(Table1),
        FILTER(
            Table1,
            Table1[Id] = Table2[Id]
        )
    )

VAR t1Count1 =
    CALCULATE(
        SUM(Table1[Values]),
        FILTER(
            Table1,
            Table1[Id] = Table2[Id]
        )
    )

RETURN 
    IF(
        t1Rows - t1Count1 = 0,
        "Yes",
        "No"
    )

 

View solution in original post

2 REPLIES 2
ChrisMendoza Senior Member
Senior Member

Re: Adding a new derived column to an existing table from a related table

@Kirthana67 -

Does this work for you?

Column = 
VAR t1Rows =
    CALCULATE(
        COUNTROWS(Table1),
        FILTER(
            Table1,
            Table1[Id] = Table2[Id]
        )
    )

VAR t1Count1 =
    CALCULATE(
        SUM(Table1[Values]),
        FILTER(
            Table1,
            Table1[Id] = Table2[Id]
        )
    )

RETURN 
    IF(
        t1Rows - t1Count1 = 0,
        "Yes",
        "No"
    )

 

View solution in original post

Kirthana67 Frequent Visitor
Frequent Visitor

Re: Adding a new derived column to an existing table from a related table

Thanks you, @ChrisMendoza. It worked!

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 6 members 1,954 guests
Please welcome our newest community members: