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
mabuzaid1993
New Member

New column to Count one to many

Hi im super new to power bi , 

The structure i have is 2 tables , programs and projects .

I need a simple new column in my programs table that counts the amount of projects for each program that i have

knowing that i have a one to many relationship with 1 program that have many projects.

 

 

 

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

NewColumn=COUNTROWS(RELATEDTABLE(Projects))

View solution in original post

2 REPLIES 2
wdx223_Daniel
Super User
Super User

NewColumn=COUNTROWS(RELATEDTABLE(Projects))

KT_Bsmart2gethe
Impactful Individual
Impactful Individual

Hi @mabuzaid1993 ,

 

I do understand that you're new to Power BI, and I will do my best to explain the step as clearly as possible.

There are a few ways you can achieve the outcome:

 

Method 1: 

1. Reference projects table, then apply "Group by" function to do the count.

How to use group by: Grouping or summarizing rows - Power Query | Microsoft Docs

 

Merge the above table from step 1 to the program table.

How to merge table: Merge queries overview - Power Query | Microsoft Docs

 

Method 2: Add a Custom Column and apply the formula below

 

 Table.SelectRows(ProjectTableName, each (x)=> (x[ProjectTableColumnName] = [ProgramTableColumnName]) and (x[ProjectTableColumnName] = [ProgramTableColumnName])

 

Condition1

Condition2

You can add more conditions, joining conditions with and / or.

 

If all the above does not make sense or does not meet your expectation.

Please kindly share some sample data with sensitive information removed, and a specific solution can be provided.

 

Regards

KT

 

 

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.

Top Solution Authors
Top Kudoed Authors