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
Anonymous
Not applicable

Compare columns from 2 tables and get aggregate values

I have 2 tables ,

Table 1: my raw data table (Fact Table) It has multiple rows because of the multiple sales value

tab1.PNG

Table 2 : My forecast table which predicts the price for a particular month and It has unique rows

tab2.PNG

 

 I want to compare the columns , Country,State,Department,Description,Month in both table 1 and 2 and get the sum value of table 1 and put it in the table 2 "Sales val".This is how the resultant table 2 should look after the transformation.

tab3.PNG

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Anonymous this makes way more sense. The better approach for this would be to create the following dimension tables:

 

- A state dimension table that contains a unique row of States and country, because a State can be in one and one country.

- A department table with a unique list of departments

- A description or category table with a unique list

- A date dimension (you can easily add this from my blog post)

 

Once all above are in the model, set the relationship between your sales and forecast table with each dimension, it will one to many relationships, dimension tables will on one side of the relationship.

 

And from here everything will be super smooth, in a visual, get a column from each dimension table and sum of sales and sum of the forecast from the respective table.

 

This is the right way of doing things.

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

5 REPLIES 5
parry2k
Super User
Super User

@Anonymous this makes way more sense. The better approach for this would be to create the following dimension tables:

 

- A state dimension table that contains a unique row of States and country, because a State can be in one and one country.

- A department table with a unique list of departments

- A description or category table with a unique list

- A date dimension (you can easily add this from my blog post)

 

Once all above are in the model, set the relationship between your sales and forecast table with each dimension, it will one to many relationships, dimension tables will on one side of the relationship.

 

And from here everything will be super smooth, in a visual, get a column from each dimension table and sum of sales and sum of the forecast from the respective table.

 

This is the right way of doing things.

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous compare all column1 to x and then get the sum of compare column1 with column1 and then get the sum. ??? 

 

You should throw some sample data with the expected output. Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k I have edited my question and added some data,thanks for your time

parry2k
Super User
Super User

@Anonymous do you have any common id between these two tables that can set the relationship together. Id which is unique in Table 2?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

No there isn't any. Table 1 is a fact table and table 2 is also a fact table in a way. 

But i wanted a Dax query where i can use =calculate (sum(sales val), match the columns with table 1)

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.