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

summarize two tables

Hi,

 

I have two tables,

1. Month,  newspaper company, distribution agency,  distribution address (city),  distribution address (street name)

2. Month,  store name, customerid, customer address (city), customer address (street name)

 

I want to add  "newspaper company" and " distribution agency" to the second table, 

 

Problems:

1) Several newspaper companies distribute to the same addresses

2) Newspaper uses more than one agency and some use the same agencies

 

I tried to summarize them, but it gives me an error message that a table of multiple values was supplied where a single value was expected.

 

Can anybody help me with this?

8 REPLIES 8
V-pazhen-msft
Community Support
Community Support

@Anonymous 

Summarize is a table function used to create a Table, if you just want to move columns to another table, a column function is expected.

In this case, you should have a relationship between the tables using Month columns, so you can just use Related() to create 2 columns in Table2.

 

Column 1 = RELATED('Table1'[newspaper company])
Column 2 = RELATED('Table1'[distribution agency])

 


Paul Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

Refer:https://radacad.com/append-vs-merge-in-power-bi-and-power-query

 

You can move the column from one table to another

New Column = maxx(filter(table2,table2[Col1]= table1[col1] && table2[Col2]= table1[col2] ),table2[required_col])
New Column = maxx(filter(table1,table1[Col1]= earlier(table1[col1]) && table1[Col1]= earlier(table1[col2]) ),table1[required_col])

Anonymous
Not applicable

@amitchandak 

thanks for your answer. "maxx(filter('table1...."   almost worked!

I get the newspaper column, but it only shows for one streetname one newspaper company.

But it has to show the streetname several times, in order to show all the newspaper companies.

 

streetname Anewspaper company A
streetname Anewspaper company B
streetname Anewspaper company C

 

@V-pazhen-msft Thanks for your answer, "related" does not work. error message reads, that there is no connection in this context. (I made a connection with date), I also tried "lookupvalue" before, but error shows multiple values where single value expected

@Anonymous ,

I need to try with data.Can you share sample data and sample output.

 

mark me @

Appreciate your Kudos.

Anonymous
Not applicable

Hi,

Please show the expected result very clearly.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

@Ashish_Mathur 

Hi, 

I try to explain it in more detail.

I have actually three tables. 1) Newspaper distribution area, 2) customer info (address) , 3) newspaper distribution costs

 

I want to compare these tables to get the following results.

So, I thought to summarize them in one table is the easiest way.

I want to know:

1) How many customers are coming from areas with no newspaper distribution.

2) How many areas with newspaper distribution, but no customers

3) How much is the cost for each area, each newspaper, each distribution agency, cost per customer

 

customer IDCityWardNewspaper/Agencycount all customerscount areas with no customerscount of customers with no distribution
 TokyoShinjuku 9 Agency A 1 
zzzTokyoShinjuku 7Agency C1  
xxxTokyoShinjuku 10Agency B1  
yyyTokyoShinjuku 11 1 1

calculatetable is another option example.  You can filter one table by the second table based on need

 

sumx(summarize(calculatetable(TableA,DATESINPERIOD( DATE[DATE], MAX( DATE[DATE] ), -6, MONTH )),
TableA[ID] , "_active",distinctcount(TableA[ID])),_active)

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.