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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
brickanalyst
Resolver I
Resolver I

Can we create a calculated table and do aggregation out of two tables ?

Hello everyone,

suppose we have two tables same format (please see below)

brickanalyst_0-1718648569668.png

and 

brickanalyst_1-1718648606235.png

we have these two tables we don't have third table so can we create a table out of these two and make calculations for instance

brickanalyst_2-1718648802187.png

and does these three have to have a relationship or not ?

ask me any questions if there's
thank you.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @brickanalyst ,

1.Regarding your first question, you mentioned that the two tables do not have the same number of columns which prevents the 'UNION' function from being used.

Something like this?

vzhouwenmsft_0-1718761270342.png

vzhouwenmsft_1-1718761304469.png

Please use the 'Append' operation in 'Power query'.

vzhouwenmsft_7-1718761975018.png

 

vzhouwenmsft_3-1718761579571.png

vzhouwenmsft_8-1718762009276.png

Replaces null values ​​in columns with 0 for calculations.

vzhouwenmsft_5-1718761769841.png

vzhouwenmsft_6-1718761842393.png

DAX is mainly used to analyze data, rather than to get the data you want like SQL. Maybe 'LOOKUPVALUE' can meet your needs.

LOOKUPVALUE function (DAX) - DAX | Microsoft Learn

2.Regarding your second question, if you change the calculation method, you only need to change the DAX expression part.

Try this.

Table4 = 
VAR _table = 'Table3'
VAR _result = SUMMARIZE(_table,[project_id],[project_name],
"S_A_1", 
DIVIDE(
MAXX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_1]) ,
MINX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_1]) , 0
),
"S_A_2", 
DIVIDE(
MAXX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_2]) ,
MINX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_2]) , 0
),
"S_A_3", 
DIVIDE(
MAXX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_3]) , 
MINX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_3]) , 0
),
"S_A_4", 
DIVIDE(
MAXX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_4]) , 
MINX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_4]) , 0
),
"S_A_5", 
DIVIDE(
MAXX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_5]) , 
MINX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_5]) , 0
)
)
RETURN _result

 

vzhouwenmsft_9-1718762659816.png

 

Best Regards,
Wenbin Zhou
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

3 REPLIES 3
Anonymous
Not applicable

Hi @brickanalyst ,

The Table data is shown below:

vzhouwenmsft_0-1718693225472.png

vzhouwenmsft_1-1718693246733.png

Regarding your question, if you intend to achieve your goals through measure, please refer to the following steps.

1.Use the following DAX expression to create a table

Table = SUMMARIZE('Table1',[project_id],[project_name])

 2.Creating table-to-table relationships

vzhouwenmsft_2-1718693423377.png

3.Use the following DAX expression to create a measure

_S_A_1 = ABS(MAX('Table1'[S_A_1]) - MAX('Table2'[S_A_1]))

4.Final output

vzhouwenmsft_3-1718693484688.png

If you intend to create a calculation table, refer to the following dax expression.

Table3 = 
VAR _table = UNION('Table1','Table2')
VAR _result = SUMMARIZE(_table,[project_id],[project_name],
"S_A_1", 
ABS(
MAXX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_1]) - 
MINX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_1])
),
"S_A_2", 
ABS(
MAXX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_2]) - 
MINX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_2])
),
"S_A_3", 
ABS(
MAXX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_3]) - 
MINX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_3])
),
"S_A_4", 
ABS(
MAXX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_4]) - 
MINX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_4])
),
"S_A_5", 
ABS(
MAXX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_5]) - 
MINX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_5])
)
)
RETURN _result

vzhouwenmsft_4-1718693562321.png

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

@Anonymous 

Hello Zhou,

I really appreciate it for quick response, two things here
1) I shared a very basic example of what I'm working on right now, so I actually don't have same amount of columns that's why union doesn't work. Can we still do that? with inner join like t-sql and grab the columns we want? 

2) is there a big change if we calculate like this ('y1'!C4 - 'r1'!C4) / 'r1'!C4 ? and we have one unique common column to create relationship

please ask me if it's not clear to picture
thanks

Anonymous
Not applicable

Hi @brickanalyst ,

1.Regarding your first question, you mentioned that the two tables do not have the same number of columns which prevents the 'UNION' function from being used.

Something like this?

vzhouwenmsft_0-1718761270342.png

vzhouwenmsft_1-1718761304469.png

Please use the 'Append' operation in 'Power query'.

vzhouwenmsft_7-1718761975018.png

 

vzhouwenmsft_3-1718761579571.png

vzhouwenmsft_8-1718762009276.png

Replaces null values ​​in columns with 0 for calculations.

vzhouwenmsft_5-1718761769841.png

vzhouwenmsft_6-1718761842393.png

DAX is mainly used to analyze data, rather than to get the data you want like SQL. Maybe 'LOOKUPVALUE' can meet your needs.

LOOKUPVALUE function (DAX) - DAX | Microsoft Learn

2.Regarding your second question, if you change the calculation method, you only need to change the DAX expression part.

Try this.

Table4 = 
VAR _table = 'Table3'
VAR _result = SUMMARIZE(_table,[project_id],[project_name],
"S_A_1", 
DIVIDE(
MAXX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_1]) ,
MINX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_1]) , 0
),
"S_A_2", 
DIVIDE(
MAXX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_2]) ,
MINX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_2]) , 0
),
"S_A_3", 
DIVIDE(
MAXX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_3]) , 
MINX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_3]) , 0
),
"S_A_4", 
DIVIDE(
MAXX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_4]) , 
MINX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_4]) , 0
),
"S_A_5", 
DIVIDE(
MAXX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_5]) , 
MINX(FILTER(_table,[project_id] = EARLIER([project_id]) && [project_name] = EARLIER([project_name])),[S_A_5]) , 0
)
)
RETURN _result

 

vzhouwenmsft_9-1718762659816.png

 

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.