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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
CAOLU10
Frequent Visitor

Question: use the detailed family report and show the family size for each id

Hi Team,

I have a request that I have the original family report with detailed relations to the related ID. the final results I would like to have in Power BI is to show the total ID with the different family size by chart. Could someone help me how to make it?

I attached an sample for dummy data: the original data are the details family data with mutiple ID, I would like to create a new table with single ID plus the related number of familys and then use the different family size as the row and count the ID.  the final chart is like the last one.  I am not sure if there is any direct way to the chart without cover the table.

Thank you,

CAOLU10_0-1739247380163.png

IDNameRelations
1234ABCDaughter
1234ABCSon
1234ABCDaughter
2345CDASon
1245ACDSon
2341AADSon
1245ACDSon
1245ACDSon
2341AADSon
2341AADDaughter
1234ABCSpouse

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Thanks for the reply from Ashish_Mathur  and danextian , please allow me to add some more information:
Hi  @CAOLU10 ,

Here are the steps you can follow:

If you don't want to create a table for the effect, you can just create a calculated column:

Count of Records =
COUNTX(
    FILTER('Table',[ID]=EARLIER('Table'[ID])),[Relations])

vyangliumsft_0-1739342827314.png

Place [ID] to Y-axis and set it to Count(Distinct), place [Count of Records] to X-axis.

Set X-axis - Categorical

vyangliumsft_1-1739342870788.png

vyangliumsft_2-1739342870794.png

If you want to create a calculation table to achieve the effect, consider the following steps:

Create calculated table.

Table 2 =
SUMMARIZE(
    'Table',
    [ID],"Count of Relations",COUNTX('Table',[Relations]))

vyangliumsft_3-1739342894467.png

Place [ID] to Y-axis and set it to Count, place [Count of Records] to X-axis.

vyangliumsft_4-1739342894473.png

 

Best Regards,

Liu Yang

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

5 REPLIES 5
v-yangliu-msft
Community Support
Community Support

Thanks for the reply from Ashish_Mathur  and danextian , please allow me to add some more information:
Hi  @CAOLU10 ,

Here are the steps you can follow:

If you don't want to create a table for the effect, you can just create a calculated column:

Count of Records =
COUNTX(
    FILTER('Table',[ID]=EARLIER('Table'[ID])),[Relations])

vyangliumsft_0-1739342827314.png

Place [ID] to Y-axis and set it to Count(Distinct), place [Count of Records] to X-axis.

Set X-axis - Categorical

vyangliumsft_1-1739342870788.png

vyangliumsft_2-1739342870794.png

If you want to create a calculation table to achieve the effect, consider the following steps:

Create calculated table.

Table 2 =
SUMMARIZE(
    'Table',
    [ID],"Count of Relations",COUNTX('Table',[Relations]))

vyangliumsft_3-1739342894467.png

Place [ID] to Y-axis and set it to Count, place [Count of Records] to X-axis.

vyangliumsft_4-1739342894473.png

 

Best Regards,

Liu Yang

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

Hi Liu yang, thanks for your detailed instruction and I think this solution is the better one that I do not need to create the new table and functions. thank you

Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1739329704955.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
CAOLU10
Frequent Visitor

Hi @danextian  

Thank you so much for your quick response, this helps me a lots. I will try it and thanks also for the BI file which is easier for me to see the details. 

Lu

danextian
Super User
Super User

Hi @CAOLU10 

 

The first table would be as simple as counting the rows in the table.

Count of Records = 
COUNTROWS ( 'Table' )

danextian_1-1739250523351.png

Please see the attached pbix.

 

For the second table, you can create a calculated table to count the rows for each ID.

Family Size = 
-- Calculate the family size by counting the number of rows
-- where the ID column in the 'Table' matches the current row's ID
COUNTROWS ( 
    FILTER ( 
        'Table', 
        'Table'[ID] = EARLIER ( 'Table'[ID] ) 
    ) 
)

And then a measure to count the distinct IDs

Distinct ID = 
DISTINCTCOUNT ( 'Table'[ID] )

Add the family size column and Distinct ID measure to the visual.

 

danextian_0-1739250503494.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors