cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MaxItaly
Helper III
Helper III

Help creating a table based on another one (only distinct value)

Hello everyone,

I'm having some problems trying to create a table.

Let's say I have a table named "Table1", that has "Client", "Quantity".

I may have more rows for the same "Client" with different "Quantity", for example:

 

Client             Quantity

A                          5

A                          8

B                          3

 

 

What I'd like to do is to create another table with only a distinct value for client and for "Quantity" the sum of the related quantity.

 

Client            Quantity

A                         13

B                           3

 

 

I guess I may create the quantity via a SUMX(RELATEDTABLE('Table1'); 'Table1'[Quantity]), but what I'm not sure how to do is to create another  table that has the distinct value of the client.

Many thanks to anyone who may help me!

 

(P.S.: I have noticed that "Remove duplicates" removes ALL the rows of a duplicated value. So, if I applied that, it would remove all rows about "Client" A, right?)

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @MaxItaly,

 

You need to create a new table with the following sintax:

 

Table2 = SUMMARIZE(Table1,Table1[Client],"Quantit"y, SUM(Table1[Quantity]))

 

You can also duplicate the table on the query editor and choose transform make a group by client and sum the quantity.

 

gro.png

 

 


Regards

MFelix

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

5 REPLIES 5
MFelix
Super User
Super User

Hi @MaxItaly,

 

You need to create a new table with the following sintax:

 

Table2 = SUMMARIZE(Table1,Table1[Client],"Quantit"y, SUM(Table1[Quantity]))

 

You can also duplicate the table on the query editor and choose transform make a group by client and sum the quantity.

 

gro.png

 

 


Regards

MFelix

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Woah: you opened me a new world!
I was not aware of this.

I am still figuring out where to write that syntax, but I managed, in the meanwhile, to do it thanks to the graphic commands.

Many thanks!

But just be aware that if you just want to summarize your table you don't need to do an additional table, you can use measures and visuals to give that result and only have 1 single table.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



I know it, but way too often the tables are not optimized for Business Intelligence operations   😞

No problem, you should use the Query to optimize your data and then use the measures to make your visuals. But this is just a good practice, because duplicating tables will have an impact on your analisys but also on size of files, dependency and overall performance.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors