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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
NathanPzi
Frequent Visitor

Dependency problem between 2 tables + sort by column

Hello,

 

To put you in context, I have 2 tables: Account and Contact.

In the "Account" table, I have :
- an "Account ID" column
- an "Account" column
- a "Major Account" column created by Power Query (so it doesn't have an ID), which lists large accounts.


Example:
Line 1: Account ID: 1 / Account : CGI New York / Major Account: CGI
Line 2: Account ID: 2 / Account : CGI Paris / Major Account: CGI
Line 3 : Account ID: 3 /Account : CAPGEMINI Washington / Major Account: CAPGEMINI

 

This table is linked to the Contact table by this account ID
With in the "Contact" table,
a "Contact ID" column
an "Account ID" column
Example:
Line 1: Contact ID: 124 / Account ID: 1
Line 1: Contact ID: 127 / Account ID: 2

 

The ultimate goal is to create a segment listing all major accounts, which is automatically sorted by Nb of contacts in that major account. ( In reverse alphabetical order )


The problem is that I'd like to be able to sort (using Power BI's "Sort by column") my major account by the number of contacts inside, not by the account name.
After several tests, either it doesn't work, or I come across a circular dependency, and I'm stuck. Unfortunately, ChatGPT doesn't help either :'(

 

If anyone can help me solve this problem. Thanks a lot 🙂

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @NathanPzi ,

I create a sample dataset by myself:

vjunyantmsft_0-1702519698819.pngvjunyantmsft_1-1702519743670.png

And I'm not sure what do you mean by "the number of contacts inside", I guess the phrase means the number of different contact IDs for each Major account?
So I use this DAX:

Contact_number = DISTINCTCOUNT(Contact[Contact ID])

Then I create a table visual:

vjunyantmsft_2-1702519980176.pngvjunyantmsft_3-1702520024198.pngvjunyantmsft_4-1702520038904.png


Best Regards,
Dino Tao
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

1 REPLY 1
Anonymous
Not applicable

Hi @NathanPzi ,

I create a sample dataset by myself:

vjunyantmsft_0-1702519698819.pngvjunyantmsft_1-1702519743670.png

And I'm not sure what do you mean by "the number of contacts inside", I guess the phrase means the number of different contact IDs for each Major account?
So I use this DAX:

Contact_number = DISTINCTCOUNT(Contact[Contact ID])

Then I create a table visual:

vjunyantmsft_2-1702519980176.pngvjunyantmsft_3-1702520024198.pngvjunyantmsft_4-1702520038904.png


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

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.