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
kevin_oleary
Regular Visitor

How to add a new column based on a condition from a separate reference table?

Hello! Thanks in advance for any help you can give me. I am new to Power BI and so far I am enjoying it, especially for the ease of connecting straight to our company's DB. I have multiple tables in my data, I have identified all of the relationships between one another in PowerBI. At the moment I could use help with getting the columns I need in the way that I want for the sake of reporting. I am not comfortable putting my company's data out on the internet so I'm using a couple of quick sample tables. I have a Bills Table and a Fee table:

Bills Table
Bill NumberCustomerTotal 
1A $       450.00
2B $       275.00
3A $       640.00
4C $       120.00
5A $       915.00
6B $       385.00
7C $       290.00
8B $       150.00

 

Fee Table
Bill NumberFee Type IDFee Amount
110 $         25.90
115 $         64.30
210 $         12.99
319 $         16.47
315 $         49.56
412 $         27.95
615 $         13.29
712 $         84.50

I am trying to add a column to my bills table where BillsTable[BillNumber] = FeeTable[BillNumber], but I only want to bring in values from FeeTable[FeeAmount] where the [FeeTypeID] = 15. My desired output would be something like this:

Desired Result
Bill NumberCustomerTotal BillAdd'l Fees (Fee Type ID = 15)
1A $  450.00 $                                           64.30
2B $  275.00 $                                                  -  
3A $  640.00 $                                           49.56
4C $  120.00 $                                                  -  
5A $  915.00 $                                                  -  
6B $  385.00 $                                           13.29
7C $  290.00 $                                                  -  
8B $  150.00 $                                                  -  

Any and all help is appreciated thank you!

4 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@kevin_oleary 

you can try this

 

Column = maxx(FILTER(Fee,'Fee'[Fee Type ID]=15&&Bill[Bill Number]=Fee[Bill Number]),'Fee'[Fee Amount])
 
11.PNG




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Anonymous
Not applicable

Hi @kevin_oleary ,

 

Thanks for the reply from @ryan_mayu  the solution is excellent. If I may, I’d like to share an additional perspective:

Consider using Power Query to merge these two tables.

let
    BillsTable = Table.FromRows(
        {
            {"1", "A", 450.00},
            {"2", "B", 275.00},
            {"3", "A", 640.00},
            {"4", "C", 120.00},
            {"5", "A", 915.00},
            {"6", "B", 385.00},
            {"7", "C", 290.00},
            {"8", "B", 150.00}
        },
        {"Bill Number", "Customer", "Total"}
    ),
    FeeTable = Table.FromRows(
        {
            {"1", "10", 25.90},
            {"1", "15", 64.30},
            {"2", "10", 12.99},
            {"3", "19", 16.47},
            {"3", "15", 49.56},
            {"4", "12", 27.95},
            {"6", "15", 13.29},
            {"7", "12", 84.50}
        },
        {"Bill Number", "Fee Type ID", "Fee Amount"}
    ),
    FilteredFeeTable = Table.SelectRows(FeeTable, each [Fee Type ID] = "15"),
    AddColumn = Table.AddColumn(
        BillsTable,
        "Fee Amount",
        each try Table.SelectRows(FilteredFeeTable, (x) => x[Bill Number] = _[Bill Number]){0}[Fee Amount] otherwise null
    )
in
    AddColumn

vbofengmsft_0-1732675562056.png

 

Best Regards,

Bof

View solution in original post

This is precisely what i was looking for, thank you!

View solution in original post

Thank you for your response! I am still learning the ins and outs of PowerBI, so I am definitely saving this for the future so I can write my own Power Queries on later problems/issues that I encounter.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @kevin_oleary ,

 

Thanks for the reply from @ryan_mayu  the solution is excellent. If I may, I’d like to share an additional perspective:

Consider using Power Query to merge these two tables.

let
    BillsTable = Table.FromRows(
        {
            {"1", "A", 450.00},
            {"2", "B", 275.00},
            {"3", "A", 640.00},
            {"4", "C", 120.00},
            {"5", "A", 915.00},
            {"6", "B", 385.00},
            {"7", "C", 290.00},
            {"8", "B", 150.00}
        },
        {"Bill Number", "Customer", "Total"}
    ),
    FeeTable = Table.FromRows(
        {
            {"1", "10", 25.90},
            {"1", "15", 64.30},
            {"2", "10", 12.99},
            {"3", "19", 16.47},
            {"3", "15", 49.56},
            {"4", "12", 27.95},
            {"6", "15", 13.29},
            {"7", "12", 84.50}
        },
        {"Bill Number", "Fee Type ID", "Fee Amount"}
    ),
    FilteredFeeTable = Table.SelectRows(FeeTable, each [Fee Type ID] = "15"),
    AddColumn = Table.AddColumn(
        BillsTable,
        "Fee Amount",
        each try Table.SelectRows(FilteredFeeTable, (x) => x[Bill Number] = _[Bill Number]){0}[Fee Amount] otherwise null
    )
in
    AddColumn

vbofengmsft_0-1732675562056.png

 

Best Regards,

Bof

Thank you for your response! I am still learning the ins and outs of PowerBI, so I am definitely saving this for the future so I can write my own Power Queries on later problems/issues that I encounter.

ryan_mayu
Super User
Super User

@kevin_oleary 

you can try this

 

Column = maxx(FILTER(Fee,'Fee'[Fee Type ID]=15&&Bill[Bill Number]=Fee[Bill Number]),'Fee'[Fee Amount])
 
11.PNG




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




This is precisely what i was looking for, thank you!

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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