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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
agustinsuarez
Regular Visitor

Aggregate Values from Table A into Table B

Assume I have Table A with following structure:

 

DateChannelDeviceSessions
5/1/2016OrganicDesktop10
5/1/2016OrganicMobile5
5/1/2016OrganicTablet5
5/2/2016OrganicDesktop15
5/2/2016OrganicMobile10
5/2/2016OrganicTablet5

 

I also have Table B with following structure:

 

DateChannelImpressions
5/1/2016Organic100
5/2/2016Organic200

 

My objective is to aggregate all the sessions from Table A into Table B, with the following output:

 

DateChannelImpressionsSessions
5/1/2016Organic10020
5/1/2016Organic20030

 

As I am still very new to Power BI, I give a similar SQL expression as I would do it using this language: SUM(Sessions) FROM Table A GROUP BY channel.

 

Note that in the real data there are multiple different values for channel, and therefore I cannot just do a WHERE clause. Thanks!

1 ACCEPTED SOLUTION
tringuyenminh92
Memorable Member
Memorable Member

Hi @agustinsuarez,

 

it could be, but your model is not ideal cause it's many-many. but there is workaround for your requirement

  • Create Dates table: Dates= Calendarauto()
  • Create Channels table: Channels = values(TableA[Channel])
  • Create 4 relationships with 3 actives as picture 
  • SS = sum(TableA[Session])

Screenshot 2016-12-30 22.18.00.png

 

 

 

Details of relationships:

Screenshot 2016-12-30 22.18.48.pngScreenshot 2016-12-30 22.18.54.pngScreenshot 2016-12-30 22.18.59.pngScreenshot 2016-12-30 22.19.05.png

 

 

If this works for you please accept it as solution and also like to give KUDOS.

Best regards
Tri Nguyen

View solution in original post

6 REPLIES 6
Eric_Zhang
Microsoft Employee
Microsoft Employee

@agustinsuarez

If table A and table B are in a many to one relationship via the columns date and channel, you can create a new column, say joinkey in each table and create relationship against that new column.

In table A
joinKey = TableA[Date]&","&TableA[Channel]

In table B
JoinKey = TableB[Date]&","&TableB[Channel]

Capture.PNG

 

Check more details in the attached pbix.zip

tringuyenminh92
Memorable Member
Memorable Member

Hi @agustinsuarez,

 

it could be, but your model is not ideal cause it's many-many. but there is workaround for your requirement

  • Create Dates table: Dates= Calendarauto()
  • Create Channels table: Channels = values(TableA[Channel])
  • Create 4 relationships with 3 actives as picture 
  • SS = sum(TableA[Session])

Screenshot 2016-12-30 22.18.00.png

 

 

 

Details of relationships:

Screenshot 2016-12-30 22.18.48.pngScreenshot 2016-12-30 22.18.54.pngScreenshot 2016-12-30 22.18.59.pngScreenshot 2016-12-30 22.19.05.png

 

 

If this works for you please accept it as solution and also like to give KUDOS.

Best regards
Tri Nguyen

This can very easily be done in the query editor: In TableB you merge with TabeA on date and chanel (leave default join-type LeftOuter). Then when you expand the newly created column, you switch to "Aggregate" an choose "Sum" of Sessions.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Seth_C_Bauer
Community Champion
Community Champion

@agustinsuarez A date table linked to both of the example tables would allow you to just use your default columns without the need to create a calculation. Something simplistically that look like this.

model.JPGoutput.JPG


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG
Baskar
Resident Rockstar
Resident Rockstar

Cool dude.

 

1. Have to create one Table for Master Table . Using Dax Code like the below image 1.JPG

 

 

 

 

 

2. Have to create Relationship between Date Master to Other your Two Tables (Table A , Table B) with Date key like the below image 

  a) Date Master "Date" to Table A "Date"

  b) Date Master "Date" to Table B "Date"

 

2.JPG

 

 

 

3. Drag Date from Date Master, then Channel, Impresion , session at and all, like below

3.JPG

 

 

 

 

 

Let me know if any help

Baskar
Resident Rockstar
Resident Rockstar

Can u please tell me what is the relationship between these two tables .

 

like date to date or Channel to channel ? like this

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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