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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
NMahi1703
Frequent Visitor

Creating New Table by two tables and with filter conditions

Hi Team,

 

I need to create a table with two tables data by appyind the conditional filers as below.

Table1

Account IDID
36301811
76253291
76255567

Table2

Account NumberBilliDName
3630NAP1
3630NAP2
3630NAP3
3630NAP4
76253291P5
76253291P6
88883291P7
76254691P8
7625 P9
7625 P10
7625 P11

Above table has relationship as Table1 Account ID with Table2 of Account Number. 
Conditions to Filter Data:

1. Table1 ID is matched with Table2 BilliD then Account Number Product should map with BillId Name
2. If Table1 ID is not matched or found in Table3 BilliD then Name Rows Assoisated with Account Number Name's Should Display in Table.

OutPut:

IDName
1811P1
1811P2
1811P3
1811P4
3291P5
3291P6
5567P5
5567P6
5567P8
5567P9
5567P10
5567P11

Thanks

1 ACCEPTED SOLUTION

Hi,

Please check the below formula and the attached pbix file.

Jihwan_Kim_0-1670127499190.png

New Table =
VAR _statustable =
    DATATABLE (
        "status", STRING,
        "index", INTEGER,
        {
            { "Critical", 1 },
            { "Warning", 2 },
            { "Normal", 3 }
        }
    )
VAR _resulttable =
    SUMMARIZE (
        GENERATE (
            Table1,
            FILTER (
                Table2,
                IF (
                    COUNTROWS ( FILTER ( Table2, Table2[BilliD] = Table1[ID] ) ) > 0,
                    Table2[BilliD] = Table1[ID]
                        && Table2[Account Number] = Table1[Account ID],
                    Table2[Account Number] = Table1[Account ID]
                )
            )
        ),
        Table1[ID],
        Table2[Name],
        Table2[Acc Status]
    )
RETURN
    ADDCOLUMNS (
        _resulttable,
        "@Status",
            MAXX (
                FILTER (
                    _statustable,
                    [index]
                        = MINX (
                            FILTER (
                                _statustable,
                                [status]
                                    IN SUMMARIZE (
                                        FILTER ( _resulttable, Table1[ID] = EARLIEST ( Table1[ID] ) ),
                                        Table2[Acc Status]
                                    )
                            ),
                            [index]
                        )
                ),
                [status]
            )
    )

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

6 REPLIES 6
NMahi1703
Frequent Visitor

Hi @Jihwan_Kim ,

 

Thanks for solution but still i'm stuck with another problem with your code.
My Table2 has follwing Data

Account NumberBilliDProduct NameVersionAcc Status
3630NAP11Warning
3630NAP22Normal
3630NAP32Normal
3630NAP410Normal
76253291P52Warning
76253291P69Warning
88883291P74Critical
76254691P82Warning
7625 P96Normal
7625 P107Critical
7625 P118Normal

Here I have each Account Status Column Value may be Normal , Warning , Critical. I want to create a Staus Column as  highiest  Status value realted to each ID
Status Order is Critical , Warning , Normal.
Desired Outupt is 

IDNameStatusAcc Status
1811P1WarningWarning
1811P2WarningNormal
1811P3WarningNormal
1811P4WarningNormal
3291P5WarningWarning
3291P6WarningWarning
5567P5CriticalWarning
5567P6CriticalWarning
5567P8CriticalWarning
5567P9CriticalNormal
5567P10CriticalCritical
5567P11CriticalNormal

Thanks.

Hi,

Please check the below formula and the attached pbix file.

Jihwan_Kim_0-1670127499190.png

New Table =
VAR _statustable =
    DATATABLE (
        "status", STRING,
        "index", INTEGER,
        {
            { "Critical", 1 },
            { "Warning", 2 },
            { "Normal", 3 }
        }
    )
VAR _resulttable =
    SUMMARIZE (
        GENERATE (
            Table1,
            FILTER (
                Table2,
                IF (
                    COUNTROWS ( FILTER ( Table2, Table2[BilliD] = Table1[ID] ) ) > 0,
                    Table2[BilliD] = Table1[ID]
                        && Table2[Account Number] = Table1[Account ID],
                    Table2[Account Number] = Table1[Account ID]
                )
            )
        ),
        Table1[ID],
        Table2[Name],
        Table2[Acc Status]
    )
RETURN
    ADDCOLUMNS (
        _resulttable,
        "@Status",
            MAXX (
                FILTER (
                    _statustable,
                    [index]
                        = MINX (
                            FILTER (
                                _statustable,
                                [status]
                                    IN SUMMARIZE (
                                        FILTER ( _resulttable, Table1[ID] = EARLIEST ( Table1[ID] ) ),
                                        Table2[Acc Status]
                                    )
                            ),
                            [index]
                        )
                ),
                [status]
            )
    )

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi @Jihwan_Kim ,

Thanks for you solution,it's working and failing with one senarios as mentioned below kindly look into this issue.

 

 

Hello @Jihwan_Kim , 

Your Solution is not working for if i have Mutiple Account Id's are assosiated with Same ID. Then it's not working kindly help me with solution
Table 1: 

Account IDID
36301811
76253291
76255567
36315567

Table 2: 

Account NumberBilliDProduct NameVersionAcc Status
3630NAP11Warning
3630NAP22Normal
3630NAP32Normal
3630NAP410Normal
76253291P52Warning
76253291P69Warning
88883291P74Critical
76254691P82Warning
7625 P96Normal
7625 P107Critical
7625 P118Normal
36315567P127Normal
36315567P1310Normal
3631 P145Critical

 

Kindly Provide the Solution

Hi @Jihwan_Kim ,

 

Kindly provide the solution fo this solutions.

 

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

Jihwan_Kim_1-1669964629965.png

 

Jihwan_Kim_0-1669964604400.png

 

 

New Table = 
SUMMARIZE (
    GENERATE (
        Table1,
        FILTER (
            Table2,
            IF (
                COUNTROWS ( FILTER ( Table2, Table2[BilliD] = Table1[ID] ) ) > 0,
                Table2[BilliD] = Table1[ID]
                    && Table2[Account Number] = Table1[Account ID],
                Table2[Account Number] = Table1[Account ID]
            )
        )
    ),
    Table1[ID],
    Table2[Name]
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors