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

Lookup value based on multiple criteria from another table

Hi, how do I look up and sum up value based on on multiple criterias from another table?

 

Here, the criterias are Date and Name.

My first table is 

DateNameTotal
DecA100
DecA200
DecB100
JuneA0
JuneC0

 

My second table 

DateNameAmount
DecA5
DecA10
DecB1
JuneA5
JuneC23
JuneC5

 

Required output:

DateNameTotalAmount
DecA30015
DecB1001
JuneA05
JuneC028

 

Thank you.

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @Anonymous 

 

Add one column as a Date-Name to both the First and the Second Table with this code:

Date-Name = 'Second Table'[Date]&"-"&'Second Table'[Name]

 

Then try this code to add a new table:

Table =
ADDCOLUMNS (
    SUMMARIZE (
        'First Table',
        'First Table'[Date],
        'First Table'[Name],
        "Total", SUM ( 'First Table'[Total] )
    ),
    "Amount",
        CALCULATE (
            SUM ( 'Second Table'[Amount] ),
            ALLEXCEPT ( 'Second Table', 'Second Table'[Date-Name] )
        )
)

 

Output:

VahidDM_0-1631178418213.png

 

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

Appreciate your Kudos✌️!!

 

View solution in original post

2 REPLIES 2
V-pazhen-msft
Community Support
Community Support

@Anonymous 

The easiest method is groupby and add index to the 2 tables, link the 2 tables with index. 

Vpazhenmsft_0-1631514677754.pngVpazhenmsft_1-1631514761029.png

Vpazhenmsft_2-1631514825404.png

 

Then you can just drag columns into a table visual.

Vpazhenmsft_3-1631514870367.png

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

 

VahidDM
Super User
Super User

Hi @Anonymous 

 

Add one column as a Date-Name to both the First and the Second Table with this code:

Date-Name = 'Second Table'[Date]&"-"&'Second Table'[Name]

 

Then try this code to add a new table:

Table =
ADDCOLUMNS (
    SUMMARIZE (
        'First Table',
        'First Table'[Date],
        'First Table'[Name],
        "Total", SUM ( 'First Table'[Total] )
    ),
    "Amount",
        CALCULATE (
            SUM ( 'Second Table'[Amount] ),
            ALLEXCEPT ( 'Second Table', 'Second Table'[Date-Name] )
        )
)

 

Output:

VahidDM_0-1631178418213.png

 

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

Appreciate your Kudos✌️!!

 

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.